我的项目是通过Hibernate来进行数据库操作的
关于MySQL连接超时问题,估计很多人都遇到过:大致情形都是这样,开发测试时程序都是正常的,一到第二天就出先莫名错误,比如在我的项目中就是定时任务执行,每天凌晨一点执行一次,也就是24小时每隔24小时执行,远远超出了8小时
如果你刚好在数据库超时的第一时间内看到日志记录的话那么,第一次超时发生的错误就是这样的:
ERROR [org.hibernate.util.JDBCExceptionReporter] - Communications link failure
Last packet sent to the server was 0 ms ago.
如果不是第一次超时后执行,以后每次报错就变成嵌套的错误了,就是下面这样:
ERROR [org.hibernate.util.JDBCExceptionReporter] -
No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error:
** BEGIN NESTED EXCEPTION **
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
MESSAGE: The last packet successfully received from the server was86395 milliseconds ago.The last packet sent successfully to the server was 86395 milliseconds ago, which is longer than the