oracle jdbc串連報錯:違反協議

來源:互聯網
上載者:User

標籤:

oracle版本:11.2.0.2

?串連方式:spring jdbctemplate串連資料庫,通過ClassPathXmlApplicationContext("vodbossContext.xml")載入設定檔。

在做單元測試包如下錯誤:

org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (違反協議)

at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:82)

at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:577)

at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:792)

at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:850)

at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:858)

at com.topdvte.vodsea.client.dao.VodCustDao.insert(VodCustDao.java:21)

at com.topdvte.vodsea.client.dao.VodCustDaoTest.testInsert(VodCustDaoTest.java:40)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.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)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (違反協議)

at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)

at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)

at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)

at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(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 oracle.jdbc.ttc7.O3log.receive2nd(O3log.java:521)

at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:262)

at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:307)

at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:442)

at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:321)

at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)

at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)

at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)

at org.apache.commons.dbcp.BasicDataSource.createDataSource(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 oracle.jdbc.ttc7.O3log.receive2nd(O3log.java:521)

 

oracle jdbc串連報錯:違反協議

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.