使用Druid鏈接池進行Oracle插入數據時,有時成功,有時失敗,成功率基本維持爲50%左右,這種非徹底失敗的狀況使人挺鬱悶的,報錯內容以下:java
java.sql.SQLException: Closed Statement at oracle.jdbc.driver.OracleClosedStatement.exitImplicitCacheToActive(OracleClosedStatement.java:2955) at oracle.jdbc.driver.OraclePreparedStatementWrapper.exitImplicitCacheToActive(OraclePreparedStatementWrapper.java:1247) at com.alibaba.druid.util.OracleUtils.exitImplicitCacheToActive(OracleUtils.java:80) at com.alibaba.druid.pool.PreparedStatementPool.get(PreparedStatementPool.java:66) at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:344) at com.service.DataService.insertOracle(DataService.java:175) at com.service.DataService.getDataToOracle(DataService.java:38) at com.MainApp.main(MainApp.java:18) java.lang.NullPointerException at com.service.DataService.insertOracle(DataService.java:383) at com.service.DataService.getDataToOracle(DataService.java:38) at com.MainApp.main(MainApp.java:18)
一直在查是不是Druid的問題,但後來發現Oracle的版本是11.2的,而使用的是odbc8.jar,後來更換爲odbc6.jar就不報錯了,插入數據都正常。sql