日期:2014-05-18  浏览次数:20720 次

jsp和oracle连接问题
程序代码:
<%Class.forName( "oracle.jdbc.driver.OracleDriver ").newInstance();  
String   url= "jdbc:oracle:thin:@192.168.1.2:1521:dingjun ";  

String   user= "system ";  
String   password= "manager ";  
Connection   conn=   DriverManager.getConnection(url,user,password);  
Statement   stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);//建立可滚动的查询结果
String   sql= "select   *   from   vol1 ";  
ResultSet   rs=stmt.executeQuery(sql);  
while(rs.next())   {%>  
您的第一个字段内容为: <%=rs.getString(1)%>  
您的第二个字段内容为: <%=rs.getString(2)%>  
<%}%>  
<%out.print( "数据库操作成功,恭喜你 ");%>  
<%rs.close();  
stmt.close();  
conn.close();  
%>

错误页面:
type   Exception   report

message  

description   The   server   encountered   an   internal   error   ()   that   prevented   it   from   fulfilling   this   request.

exception  

org.apache.jasper.JasperException:   Exception   in   JSP:   /test.jsp:10

7:   </head>
8:  
9:   <body>
10:   <%Class.forName( "oracle.jdbc.driver.OracleDriver ").newInstance();  
11:   String   url= "jdbc:oracle:thin:@192.168.1.2:1521:dingjun ";  
12:  
13:   String   user= "system ";  


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:506)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root   cause  

javax.servlet.ServletException:   oracle.jdbc.driver.OracleDriver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:843)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:776)
org.apache.jsp.test_jsp._jspService(test_jsp.java:91)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root   cause  

java.lang.ClassNotFoundException:   oracle.jdbc.driver.OracleDriver
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1355)
org.apache.catalina.loader.WebappClassLoader.loadClass(Weba