<分区>
有时,我的 Java/Tomcat6/Debian Squeeze 应用程序无法与 MySql 服务器通信。 Tomcat 应用程序位于前端服务器上,而 MySql 位于单独的、仅支持 MySql 的机器上。一个典型的错误是:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was56588 milliseconds ago.
The last packet sent successfully to the server was 56588 milliseconds ago, which
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
server configured values for client timeouts, or using the Connector/J connection property
'autoReconnect=true' to avoid this problem.
给出的超时时间只有60秒,显得很短。如果是一个小时或更长时间,我会简单地设置一个后台任务,每隔几分钟 ping 一次数据库服务器。我已将 autoReconnect 参数添加到打开的 URL,没有明显影响。
知道这里的问题是什么吗? 谢谢 帕特