com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 59,873,183 milliseconds ago.  
The last packet sent successfully to the server was 59,873,186 milliseconds ago. is longer than the server configured value of 'wait_timeout'. 
You should consider either expiring and/or testing connection validity before use in your application, increasing the serve

在建立與MySQL的連接之後超過8個小時沒有再一次使用該鏈接,會報連接超時異常。
解決方法:
1、修改MySQL的wait timeout值,改成一個比28800大的值。比如864000,也就是該鏈接可以保持10天。wait_timeout=864000。但是最大值爲2147483,超過之後還是會被解析爲2147483。
2、在要使用該連接之前先判斷是否超時,如果超時,就重新建立連接。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章