com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 11,226 milliseconds ago.
Caused by: java.net.SocketException: Connection reset by peer: socket write error
两种解决异常:“The last packet successfully received from the server was 11,226 milliseconds ago. ”的办法
出现异常”The last packet successfully received from the server was 11,226 milliseconds ago. “的大部分原因是由于数据库回收了连接,而系统的缓冲池不知道,继续使用被回收的连接所致的。
以mysql为例:
第一种解决办法,就是将mysql回收空闲连接的时间变长,mysql默认回收时间是8小时,可以在mysql目录下的my.ini(my.defaultini)中增加下面配置,将时间改为1天。
单位是秒,最大好像是24天:
[mysqld]
wait_timeout=86400
interactive_timeout=86400