开发者社区> 问答> 正文

springboot+Atomikos+Druid+mybiats下mysql连?400报错

使用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);

 

 

展开
收起
爱吃鱼的程序员 2020-06-06 21:10:10 675 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <p>你设置数据源了,就没必要setXaDataSourceClassName了<br> <img height="217" src="https://oscimg.oschina.net/oscnet/470ed0fb338e8e5127a81f26f5046fc2d07.jpg" width="827"></p>
    
    2020-06-06 21:10:26
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
搭建电商项目架构连接MySQL 立即下载
搭建4层电商项目架构,实战连接MySQL 立即下载
PolarDB MySQL引擎重磅功能及产品能力盛大发布 立即下载

相关镜像