例外是:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was45569 milliseconds ago.The last packet sent successfully to the server was 45569 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.
答案 0 :(得分:2)
可能发生的事情是,C3P0池中的连接被MySQL关闭,因为它保持打开的时间比interactive_timeout(http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_interactive_timeout)
更长您可能需要配置c3p0来测试连接,如下所述:http://www.mchange.com/projects/c3p0/index.html#configuring_connection_testing
答案 1 :(得分:1)
这意味着应用程序和数据库之间的网络连接已断开。
这可能由于各种原因(网络故障或连接超时)而发生。最后一句基本上是如何解决问题。
您可以尝试更改设置以使连接不易发生故障/断开,或者配置JDBC驱动程序以处理故障/断开连接并自动重新连接。
注意:您不应该长时间直接保持连接。从池中获取连接,使用它,然后将其释放回池中。池为您管理连接。