Mysql 连接问题:No operations allowed after connection closed.
来源:18-1 课程总结

hthonor
2020-11-04
使用阿里云上的mysql数据库,就出现这个问题了,之前在本地没有出现过。
网上说要修改连接池的配置,
不过 content-center 、user-center中都没有使用连接池呀
请问大目老师,应该怎么设置?
10:15:44.052 ERROR 8883 --- [nio-8020-exec-8] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30051ms.
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30051ms.] with root cause
com.mysql.cj.exceptions.ConnectionIsClosedException: No operations allowed after connection closed.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_65]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_65]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_65]
at java.lang.reflect.Constructor.newInstance(Constructor.java:422) ~[na:1.8.0_65]
2回答
-
大目
2020-11-04
content-center 、user-center 都是用了连接池的啊,用的HikariCP。
检查下你连接数据库的相关配置吧。
00 -
hthonor
提问者
2020-11-04
我这样加了配置,暂时还没报错
spring:
datasource:
hikari:
# 连接池最大连接数,默认是 10
maximum-pool-size: 60
# 链接超时时间,默认 30000(30 秒)
connection-timeout: 60000
# 空闲连接存活最大时间,默认 600000(10 分钟)
idle-timeout: 60000
# 连接将被测试活动的最大时间量
validation-timeout: 3000
# 此属性控制池中连接的最长生命周期,值 0 表示无限生命周期,默认 1800000(30 分钟)
max-lifetime: 60000
# 连接到数据库时等待的最长时间(秒)
login-timeout: 5
# 池中维护的最小空闲连接数
minimum-idle: 10
00
相似问题