错误描述
这里我使用 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