首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

tomcat连接oracle9有关问题

2011-12-27 
tomcat连接oracle9问题代码%@pagecontentType text/htmlcharsetgb2312 language java import j

tomcat连接oracle9问题
代码
<%@page   contentType= "text/html;charset=gb2312 "   language= "java "   import= "java.sql.* "%>
<%@page   import= "java.io.* "%>
<%@page   import= "java.lang.* "%>
<html>
            <body>
            以下是从Oracle数据库读取的数据: <hr>
            <table   border=1>
                    <tr> <td> id </td> <td> 书名 </td> <td> 出版社 </td> <td> 价格 </td> </tr>
            <%


                    Class.forName( "oracle.jdbc.driver.OracleDriver ").newInstance();
                    String   url= "jdbc.oracle:thin:@localhost:1521:oracle ";
                    String   uid= "system ";
                    String   pwd= "system ";
                    Connection   con=DriverManager.getConnection(url,uid,pwd);
                      out.println(DriverManager.getConnection(url,uid,pwd));

                        Statement   stmt=con.createStatement();

                    ResultSet   rst=stmt.executeQuery( "select   *   from   system.book ");
                    while(rst.next()){
                    out.println( " <tr> ");
                    out.println( " <td> "+rst.getString( "BOOKID ")+ " </td> ");
           
                    }
                rst.close();
                stmt.close();
                con.close();

            %>

            </table>
            </body>
</html>
错误:
javax.servlet.ServletException:   No   suitable   driver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.Oracle_jsp._jspService(Oracle_jsp.java:93)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root   cause  
java.sql.SQLException:   No   suitable   driver
java.sql.DriverManager.getConnection(DriverManager.java:532)


java.sql.DriverManager.getConnection(DriverManager.java:171)
org.apache.jsp.Oracle_jsp._jspService(Oracle_jsp.java:61)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)



[解决办法]
oracle jdbc的classpath指对了吗?

驱动没有效果哦


[解决办法]
把oracle驱动放到tomcat\common\lib目录中。

热点排行