springboot+Atomikos+Druid+mybiats下mysql连接正常,oracle连接不正常
使用com.alibaba.druid.pool.xa.DruidXADataSource时Mysql连接正常,oracle连接不正常,oracle使用的是ojdbc6,代码片段
AtomikosDataSourceBean adsb = new AtomikosDataSourceBean();
DruidXADataSource druidXADataSource = (DruidXADataSource)ds;
druidXADataSource.setName(dataSourceName);
initDruidFilters(druidXADataSource);
adsb.setUniqueResourceName(dataSourceName);
adsb.setXaDataSourceClassName(druidXADataSource.getClass().getName());
adsb.setXaDataSource(druidXADataSource);
targetDataResources.put(dataSourceName,adsb);
访问Oracle数据库报错,其中输出druidXADataSource连接信息都正常:
java.lang.NullPointerException: null
at oracle.jdbc.driver.PhysicalConnection.cacheBuffer(PhysicalConnection.java:6811)
at oracle.jdbc.driver.OraclePreparedStatement.releaseBuffers(OraclePreparedStatement.java:3012)
at oracle.jdbc.driver.T4CPreparedStatement.releaseBuffers(T4CPreparedStatement.java:241)
at oracle.jdbc.driver.OraclePreparedStatement.enterImplicitCache(OraclePreparedStatement.java:3094)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.enterImplicitCache(OraclePreparedStatementWrapper.java:1588)
at com.alibaba.druid.util.OracleUtils.enterImplicitCache(OracleUtils.java:65)
at com.alibaba.druid.pool.PreparedStatementPool.put(PreparedStatementPool.java:83)
at com.alibaba.druid.pool.DruidPooledConnection.closePoolableStatement(DruidPooledConnection.java:163)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.close(DruidPooledPreparedStatement.java:201)
at com.atomikos.jdbc.AbstractConnectionProxy.forceCloseAllPendingStatements(AbstractConnectionProxy.java:63)
at com.atomikos.jdbc.AtomikosConnectionProxy.close(AtomikosConnectionProxy.java:240)
at com.atomikos.jdbc.AtomikosConnectionProxy.invoke(AtomikosConnectionProxy.java:155)
但是调整为com.alibaba.druid.pool.DruidDataSource,Oracle数据的db-type指定为mysql时,下面代码Mysql和Oracle都可以访问
DruidDataSource druidDataSource = (DruidDataSource)ds;
druidDataSource.setName(dataSourceName);
initDruidFilters(druidDataSource);
targetDataResources.put(dataSourceName,druidDataSource);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你设置数据源了,就没必要setXaDataSourceClassName了