解决com.kingbase8.util.KSQLException: This _connection has been closed.
问题描述
一个消息管理系统,系统采用kingbase8数据库,数据库采用单体模式,后台应用也采用springboot单体模式。系统正式上线后,出现几个JDBC响应的异常信息:
- com.kingbase8.util.KSQLException: An I/O error occurred while sending to the backend.
- java.net.SocketTimeoutException: Read timed out.
- com.kingbase8.util.KSQLException: This _connection has been closed.
- org.springframework.dao.DataAccessResourceFailureException: JDBC rollback; This _connection has been closed.; nested exception is com.kingbase8.util.KSQLException: This _connection has been closed.
完整错误日志如下:
2025-01-24 15:28:34.585 [http-nio-8015-exec-2] [1;31mERROR[0;39m [36mdruid.sql.Statement:148[0;39m - {conn-10720, pstmt-2487241} execute error. UPDATE ehc_task SET name = ?, event_type_code = ?, task_type = ?, start_time = ?, end_time = ?, start_time_cycle = ?, end_time_cycle = ?, event_type_name = ?, content = ?, is_flow = ?, initiator = ?, handle_status = ?, lamp_color = ?, status = ?, create_user_id = ?, create_user_name = ?, handle_dimension = ?, type = ?, task_uid = ?, union_id = ?, union_name = ?, is_expire = ?, is_urgent = ?, create_by = ?, create_time = ?, update_by = ?, update_time = ? WHERE id = ? AND is_del = 0
java.sql.BatchUpdateException: Batch entry 0 UPDATE ehc_task SET name = '测试事件', event_type_code = 'SJSN', task_type = 1, start_time = '2025-01-01 00:00:00+08', end_time = '2025-01-27 00:00:00+08', start_time_cycle = '', end_time_cycle = '', event_type_name = '工作盯盯', content = '测试内容', is_flow = '0', initiator = '蹇杨', handle_status = 2, lamp_color = '#FFCE20', status = 2, create_user_id = '1802631429172006913', create_user_name = '蹇杨', handle_dimension = 2, type = 2, task_uid = '2a159287', union_id = 6, union_name = '成都市武侯区总工会', is_expire = '0', is_urgent = '0', create_by = '蹇杨', create_time = '2025-01-23 13:42:48.833+08', update_by = '朱燕', update_time = '2025-01-24 15:28:24.54+08' WHERE id = 1553 AND is_del = 0 was aborted: An I/O error occurred while sending to the backend. Call getNextException to see other _errors in the batch.
at com.kingbase8.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:286)
at com.kingbase8.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:674)
at com.kingbase8.jdbc.KbStatement.internalExecuteBatch_(KbStatement.java:1403)
at com.kingbase8.jdbc.KbStatement.executeBatch(KbStatement.java:1438)
at com.kingbase8.jdbc.KbPreparedStatement.executeBatch(KbPreparedStatement.java:3051)
at com.alibaba.druid.filter.FilterChainImpl.statement_executeBatch(FilterChainImpl.java:3101)
at com.alibaba.druid.filter.FilterAdapter.statement_executeBatch(FilterAdapter.java:2506)
at com.alibaba.druid.filter.FilterEventAdapter.statement_executeBatch(FilterEventAdapter.java:273)
at com.alibaba.druid.filter.FilterChainImpl.statement_executeBatch(FilterChainImpl.java:3099)
at com.alibaba.druid.filter.FilterAdapter.statement_executeBatch(FilterAdapter.java:2506)
at com.alibaba.druid.filter.FilterEventAdapter.statement_executeBatch(FilterEventAdapter.java:273)
at com.alibaba.druid.filter.FilterChainImpl.statement_executeBatch(FilterChainImpl.java:3099)
at com.alibaba.druid.proxy.jdbc.StatementProxyImpl.executeBatch(StatementProxyImpl.java:198)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeBatch(DruidPooledPreparedStatement.java:551)
at org.apache.ibatis.executor.BatchExecutor.doFlushStatements(BatchExecutor.java:123)
at org.apache.ibatis.executor.BaseExecutor.flushStatements(BaseExecutor.java:129)
at org.apache.ibatis.executor.BaseExecutor.flushStatements(BaseExecutor.java:122)
at org.apache.ibatis.executor.CachingExecutor.flushStatements(CachingExecutor.java:114)
at sun.reflect.GeneratedMethodAccessor100.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:64)
at com.sun.proxy.$Proxy401.flushStatements(Unknown Source)
at sun.reflect.GeneratedMethodAccessor100.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:64)
at com.sun.proxy.$Proxy401.flushStatements(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.flushStatements(DefaultSqlSession.java:249)
at com.baomidou.mybatisplus.extension.toolkit.SqlHelper.lambda$executeBatch$1(SqlHelper.java:224)
at com.baomidou.mybatisplus.extension.toolkit.SqlHelper.executeBatch(SqlHelper.java:182)
at com.baomidou.mybatisplus.extension.toolkit.SqlHelper.executeBatch(SqlHelper.java:217)
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.executeBatch(ServiceImpl.java:240)
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.updateBatchById(ServiceImpl.java:192)
at com.baomidou.mybatisplus.extension.service.IService.updateBatchById(IService.java:268)
at com.baomidou.mybatisplus.extension.service.IService$$FastClassBySpringCGLIB$$f8525d18.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
at org.jeecg.modules.eventhub.dao.impl.EhcTaskDaoImpl$$EnhancerBySpringCGLIB$$7771ddc5.updateBatchById(<generated>)
at org.jeecg.modules.base.task.TaskJob.updateLampColor(TaskJob.java:306)
at org.jeecg.modules.base.task.TaskJob$$FastClassBySpringCGLIB$$13b3c93b.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy.invokeMethod(CglibAopProxy.java:386)
at org.springframework.aop.framework.CglibAopProxy.access$000(CglibAopProxy.java:85)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:704)
at org.jeecg.modules.base.task.TaskJob$$EnhancerBySpringCGLIB$$aa5db2df.updateLampColor(<generated>)
at org.jeecg.modules.eventhub.