Open zj4775 opened 6 years ago
atomikos遇到同样问题 druid 1.1.5 mysql5.6.38 atomikos分布式事务
java.sql.SQLException: connection holder is null
at com.alibaba.druid.pool.DruidPooledConnection.checkStateInternal(DruidPooledConnection.java:1138)
at com.alibaba.druid.pool.DruidPooledConnection.checkState(DruidPooledConnection.java:1131)
at com.alibaba.druid.pool.DruidPooledConnection.getMetaData(DruidPooledConnection.java:860)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.atomikos.jdbc.AtomikosConnectionProxy.invoke(AtomikosConnectionProxy.java:161)
at com.sun.proxy.$Proxy235.getMetaData(Unknown Source)
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:331)
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:366)
at org.springframework.jdbc.support.SQLErrorCodesFactory.getErrorCodes(SQLErrorCodesFactory.java:212)
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.setDataSource(SQLErrorCodeSQLExceptionTranslator.java:134)
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.
@wenshao
@zj4775 如果你们用的atomikos的话。。初步判断原因是atomikos的ConnectionPool自己维护了一个连接池,每次borrowConnection的时候,它从自己的连接池里面取,所以有可能druid在shrink之后把某个连接回收了,atomikos这边仍然持有这个连接,导致了connection holder is null。。
遇到了同样的问题: druid:1.1.9 mysq:5.5.33 java:1.7
添加了keepAlive=true也不起作用,最后升级了mysql-connector-java版本,问题得解。
你用atomikos 没有8小时超时的问题 ?能否看下你的数据源配置?
我没有使用 atomikos,目前项目没有正式启用,暂时还没发现8小时问题。 数据源配置可以留下邮箱我给您发邮件。
@hitynsun 不用了 我在使用过程中,atomikos +druid 是不行的,应该是无法配合使用的,超8小时 jdbc链接就无法使用了 现在也不用druid 了
有解决方案吗?
Caused by: java.sql.SQLException: connection disabled at com.alibaba.druid.pool.DruidPooledConnection.checkStateInternal(DruidPooledConnection.java:1162) at com.alibaba.druid.pool.DruidPooledConnection.checkState(DruidPooledConnection.java:1147) at com.alibaba.druid.pool.DruidPooledConnection.getAutoCommit(DruidPooledConnection.java:735) at sun.reflect.GeneratedMethodAccessor272.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.atomikos.jdbc.AtomikosConnectionProxy.invoke(AtomikosConnectionProxy.java:141) at com.sun.proxy.$Proxy159.getAutoCommit(Unknown Source) at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:83) at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:68) at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:336) at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:85) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) at sun.reflect.GeneratedMethodAccessor281.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) ... 82 common frames omitted
出现同样问题,请问各位都怎么解决的?
请问有解决方案吗
closeConnOnFatalError
to false
, Druid's behavior will align with HikariCP, that is, the connection will no longer be closed when a fatal error defined by Druid occurs. This solves a series of controversies surrounding Hibernate, Flyway, and ShardingSphere. This is a huge regret introduced from https://github.com/alibaba/druid/commit/882470b1ce7a51a94f3525beceec91384ccd425f 7 years ago.
温少你好,我们最近使用druid出现了connection holder is null 的异常,参考前面的 文章你说需要将druid提升到1.1.5,我们已经将druid的版本提升到了1.1.8版本了,但是程序跑了几天还是会出现这个错误。 druid的配置信息是 filters=stat,config maxActive=20 initialSize=1 maxWait=60000 minIdle=1 maxIdle=10 timeBetweenEvictionRunsMillis=60000 minEvictableIdleTimeMillis=300000 validationQuery=SELECT 'x' testWhileIdle=true testOnBorrow=false testOnReturn=false maxOpenPreparedStatements=20 removeAbandoned=false removeAbandonedTimeout=1800
具体版本是 druid:1.1.8 mysql-connector-java:5.1.34 mysql:5.6.16
我们使用的是分布式事务会出现这个问题