当前位置: 代码迷 >> Java Web开发 >> JDBC连接oracle10g
  详细解决方案

JDBC连接oracle10g

热度:171   发布时间:2010-08-28 00:03:45.0
JDBC连接oracle10g
我们实验室,web服务器和database服务器是分开的。我的JDBC连接步骤,在oracle的安装目录下找到classes.jar放在resin的lib目录下(我们的web用的resin的服务器。又在oracle的安装目录下找到jdk14.jar放在jdk的lib目录下。
然后写了一段代码
<%@ page contentType = "text/html; charset = gb2312"  import ="java.sql.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
  <head>
    <base href="<%=basePath%>">
   
    <title>My JSP 'MyJsp.jsp' starting page</title>
   
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">   
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

  </head>
  
  <body>
    <%
Class. forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url ="jdbc:oracle:thin:@172.16.9.196:1521:BIOINFG";
String username ="GN";
String password ="micrarray"
Connection con = DriverManager.getConnection(url,username,password);
Statement stme =con.creatStatement(ResultSet.TYPE_SCROLL_INSENSTIVE, ResultSet.CONCUR_READ_ONLY);
String sql = “select * from student":
ResultSet rs = stme.executeQuery(sql);
while(rs.next()){
System.out.println("数据库服务器连接成功。”);
%>

  </body>
</html>
但是系统给出了这样的报错信息:
500 Servlet Exception

[show] /JDBC1.jsp:1: expected '%>' at '"'.  JSP directive syntax is '<%@ name
attr1='value1' ... %>'.  (Started at line 1)

1:  <%@ page contentType = "text/html; charset = gb2312" import"java.sql.*"%>
2:  <%
3:  String path = request.getContextPath();


我不太清楚这是怎么回事,希望老师指导一下。
搜索更多相关主题的帖子: JDBC  

----------------解决方案--------------------------------------------------------
  相关解决方案