springboot+Atomikos+Druid+mybiats下mysql连?400报错-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

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

爱吃鱼的程序员 2020-06-06 21:10:10 83

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

 

 

Oracle 关系型数据库 MySQL 数据库
分享到
取消 提交回答
全部回答(1)
  • 爱吃鱼的程序员
    2020-06-06 21:10:26
                        <p>你设置数据源了,就没必要setXaDataSourceClassName了<br> <img height="217" src="https://oscimg.oschina.net/oscnet/470ed0fb338e8e5127a81f26f5046fc2d07.jpg" width="827"></p>
    
    0 0
数据库
使用钉钉扫一扫加入圈子
+ 订阅

分享数据库前沿,解构实战干货,推动数据库技术变革

推荐文章
相似问题
推荐课程