开发者社区> 问答> 正文

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 678 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
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
云栖社区特邀专家徐雷Java Spring Boot开发实战系列课程(第20讲):经典面试题与阿里等名企内部招聘求职面试技巧 立即下载
微服务架构模式与原理Spring Cloud开发实战 立即下载
阿里特邀专家徐雷Java Spring Boot开发实战系列课程(第18讲):制作Java Docker镜像与推送到DockerHub和阿里云Docker仓库 立即下载

相关镜像