批量执行到一半报错:No operations allowed after statement closed

错误描述

这里我使用 mybatis plus 进行批量修改时发生报错:

org.springframework.dao.TransientDataAccessResourceException: 
### Error querying database.  Cause: java.sql.SQLException: No operations allowed after statement closed.
### The error may exist in com/test/TestMapper.java (best guess)
### The error may involve com.test.mapper.TestMapper.selectById
### The error occurred while executing a query
### Cause: java.sql.SQLException: No operations allowed after statement closed.
; No operations allowed after statement closed.; nested exception is java.sql.SQLException: No operations allowed after statement closed.
	at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:110)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQ

报错显示正在执行但是连接被关闭了。

解决方案

我这里使用的数据库连接池是 druid,修改连接超时时间配置即可:

spring:
	druid:
	   time-between-eviction-runs-millis: 60000
	   min-evictable-idle-time-millis: 300000

相关推荐

  1. npm安装完执行找不 package.json

    2024-04-20 14:48:07       42 阅读
  2. mac执行python3 --version

    2024-04-20 14:48:07       30 阅读
  3. Kafka下沉HDFS

    2024-04-20 14:48:07       57 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-20 14:48:07       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-20 14:48:07       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-20 14:48:07       87 阅读
  4. Python语言-面向对象

    2024-04-20 14:48:07       96 阅读

热门阅读

  1. 关系数据库设计的基本步骤及其产物

    2024-04-20 14:48:07       32 阅读
  2. Elasticsearch .NET 客户端的演变

    2024-04-20 14:48:07       35 阅读
  3. 搜维尔科技:Manus Xsens Metagloves新一代手指捕捉

    2024-04-20 14:48:07       30 阅读
  4. 使用Git进行版本控制

    2024-04-20 14:48:07       32 阅读
  5. Spring的循环依赖问题如何解决

    2024-04-20 14:48:07       35 阅读
  6. 美国家安全局等发布安全部署人工智能系统指南

    2024-04-20 14:48:07       39 阅读
  7. MySQL 高级技巧

    2024-04-20 14:48:07       38 阅读
  8. ubuntu系统下opencv的编译安装

    2024-04-20 14:48:07       40 阅读
  9. Controller配置总结(SpringMVC学习笔记二)

    2024-04-20 14:48:07       35 阅读