oraclejdbc连接报错:违反协议
oracle版本:11.2.0.2
连接⽅式:spring jdbctemplate连接数据库,通过ClassPathXmlApplicationContext("l")加载配置⽂件。在做单元测试包如下错误:
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apachemons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (违反协议)
at org.springframework.jdbc.Connection(DataSourceUtils.java:82)
at org.ute(JdbcTemplate.java:577)
at org.JdbcTemplate.update(JdbcTemplate.java:792)
at org.JdbcTemplate.update(JdbcTemplate.java:850)
at org.JdbcTemplate.update(JdbcTemplate.java:858)
pdvte.vodsea.client.dao.VodCustDao.insert(VodCustDao.java:21)
pdvte.vodsea.client.stInsert(VodCustDaoTest.java:40)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at flect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
lipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
lipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
lipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
lipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
lipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
lipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.apachemons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (违反协议)
at org.apachemons.ateDataSource(BasicDataSource.java:1225)
java的jdbc连接数据库
at org.apachemons.Connection(BasicDataSource.java:880)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
at org.springframework.jdbc.Connection(DataSourceUtils.java:79)
... 25 more
Caused by: java.sql.SQLException: 违反协议
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:944)
at ive2nd(O3log.java:521)
at 7.TTC7Protocol.logon(TTC7Protocol.java:262)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:307)
at oracle.jdbc.ConnectionInstance(OracleDriver.java:442)
at oracle.jdbc.t(OracleDriver.java:321)
at org.apachemons.ateConnection(DriverConnectionFactory.java:38) at org.apachemons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294) at org.apachemons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)
at org.apachemons.ateDataSource(BasicDataSource.java:1221)
... 28 more
这个问题查了⼤半天,对⼀下⼏点做出:
1、jdbc配置出错
2、⽤户密码不对
3、查看oracle错误⽇志,不是很会查看
4、oracle驱动版本不对
对上⾯的每项都做了验证,还是不对,后来重启了下eclipse,就OK了
最终确定是oracle驱动版本不对
为啥要重启后才能⽣效,这个问题⼀直没有明⽩,有谁知道可以告知。
总结:
  错误信息提⽰就已经报错问题出在jdbc oracle包中,没有抓准,导致错⽅向,⽩忙活了。
  Caused by: java.sql.SQLException: 违反协议
  at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
  at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
  at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:944)
  at ive2nd(O3log.java:521)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。