使用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);
<p>你设置数据源了,就没必要setXaDataSourceClassName了<br> <img height="217" src="https://oscimg.oschina.net/oscnet/470ed0fb338e8e5127a81f26f5046fc2d07.jpg" width="827"></p>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。