mysql 连接池连接超时的问题(The last packet successfully received from the server was 2,431 milliseconds ago. The last packet sent successfully to the server was 2,417 milliseconds ago.)

org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 2,431 milliseconds ago.  The last packet sent successfully to the server was 2,417 milliseconds ago.
### The error may exist in com/melodyhub/mapper/UserMapper.xml
### The error may involve com.melodyhub.mapper.UserMapper.selectUser
### The error occurred while executing a query
### Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 2,431 milliseconds ago.  The last packet sent successfully to the server was 2,417 milliseconds ago.

	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
	

解决:
mysql超时设置的问题
如果连接闲置8小时 (8小时内没有进行数据库操作), mysql就会自动断开连接。

connection url中加参数: autoReconnect=true

jdbc.url=jdbc:mysql://localhost:3306/database?autoReconnect=true&autoReconnectForPools=true
posted @ 2020-08-30 21:49  MelodyJerry  阅读(2775)  评论(0编辑  收藏  举报
没有伞的孩子必须努力奔跑!|
载入天数...载入时分秒...
(っ•̀ω•́)っ✎⁾⁾ 开心每一天