java - 请教:使用ojdbc5.jar作为驱动jar包无法正常连接oracle数据库,而使用ojdbc14.jar却可以正常连接?
巴扎黑
巴扎黑 2017-04-17 17:24:12
0
0
454

最近我在练习jdbc时做了个测试jsp页面,但是发现一个恼人的问题,就是我无法使用ojdbc5.jar作为驱动jar包连接oracle数据库(因为总是报异常),而使用ojdbc14.jar却可以正常连接数据库 (plsql也能正常连接)。小弟在网上寻找可是总也找不到解决办法,所以想请教各位究竟是什么原因造成这个问题的呢?
代码如下:

login_check.jsp:

<%
     String url="jdbc:oracle:thin:@localhost:1521:HDGATE1";
     String db_user="HD_GATE";
     String db_pwd="HD_GATE";
     Class.forName("oracle.jdbc.driver.OracleDriver");    //oracle.jdbc.driver.OracleDriver
     Connection conn=DriverManager.getConnection(url,db_user,db_pwd);
     String sql= "select * from tb_users";
     Statement stmt=conn.createStatement();
     ResultSet rs=stmt.executeQuery(sql);
        rs.next();
        String i = rs.getString("USER_NAME");
        String s = rs.getString("PASSWORD");
        System.out.println("ROW = " + i + " " + s );
 %> 

异常信息:

     严重: Servlet.service() for servlet [jsp] in context with path [/test_connection] threw exception [javax.servlet.ServletException: java.sql.SQLException: IO 错误: Undefined Error] with root cause
oracle.net.ns.NetException: Undefined Error
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:395)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1102)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at org.apache.jsp.login_005fcheck_jsp._jspService(login_005fcheck_jsp.java:103)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

我的项目环境是:
OS:windows8.1 专业版
数据库:oracle 11g 64位
服务器:tomcat 7
java:jdk:1.7

巴扎黑
巴扎黑

membalas semua(0)
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!