开发者社区> 问答> 正文

大数据更新时抛出: java.sql.SQLException: connection holder

环境:linux+1.7 druid:1.0.22 生产数据量:41万更新,单条更新

异常现象: Caused by: java.sql.SQLException: connection holder is null at com.alibaba.druid.pool.DruidPooledConnection.checkStateInternal(DruidPooledConnection.java:1122) at com.alibaba.druid.pool.DruidPooledConnection.checkState(DruidPooledConnection.java:1113) at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:318) at se.spagettikod.optimist.impl.MySqlMapper.getCurrentEntityVersionInDatabase(MySqlMapper.java:41) at se.spagettikod.optimist.impl.OptimisticLockingInterceptor.updateImpl(OptimisticLockingInterceptor.java:70) at se.spagettikod.optimist.impl.OptimisticLockingInterceptor.intercept(OptimisticLockingInterceptor.java:150) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:57) at com.sun.proxy.$Proxy145.update(Unknown Source) at sun.reflect.GeneratedMethodAccessor874.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:59) at com.sun.proxy.$Proxy145.update(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145) at sun.reflect.GeneratedMethodAccessor907.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:355) ... 130 more

org.springframework.jdbc.UncategorizedSQLException:

Error updating database. Cause: java.sql.SQLException: connection holder is null Cause: java.sql.SQLException: connection holder is null ; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; connection holder is null; nested exception is java.sql.SQLException: connection holder is null at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365) at com.sun.proxy.$Proxy19.update(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:251)

配置信息: pool.initialSize=20 pool.maxActive=200 pool.maxIdle=20 pool.maxWait=10000 pool.removeAbandoned=true pool.removeAbandonedTimeout=900 pool.logAbandoned=true pool.testWhileIdle=true pool.timeBetweenEvictionRunsMillis=3000 pool.validationQuery=select 1 from dual pool.poolPreparedStatements=false pool.defaultAutoCommit=true 后来换成dbcp更新成功,没有报holder is null问题,更新数据成功

原提问者GitHub用户pandboy

展开
收起
山海行 2023-07-05 21:25:43 148 0
2 条回答
写回答
取消 提交回答
  • 北京阿里云ACE会长

    据您提供的信息,可能是因为大数据更新时出现了数据库连接池的问题,导致连接被关闭或者释放,但是在事务提交之前仍然存在未提交的操作,从而导致"connection holder"异常。

    这种情况通常是因为在事务提交之前,数据库连接已经被关闭或释放,而事务管理器无法将事务提交给关闭的连接,从而导致异常。

    2023-07-30 09:58:45
    赞同 展开评论 打赏
  • removeAbandoned=true这个关掉就好了

    原回答者GitHub用户wenshao

    2023-07-06 12:14:14
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Data+AI时代大数据平台应该如何建设 立即下载
大数据AI一体化的解读 立即下载
极氪大数据 Serverless 应用实践 立即下载