例外情况是:
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.
发布于 2012-01-02 20:52:07
可能发生的情况是,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
发布于 2011-12-13 18:39:25
这意味着应用程序和数据库之间的网络连接已中断。
发生这种情况的原因有很多(网络故障或连接超时)。最后一句话主要是关于如何解决这个问题。
您可以尝试更改设置以降低连接失败/断开的可能性,也可以将JDBC驱动程序配置为处理失败/断开连接并自动重新连接。
注意:不能长时间保持直接连接。从池中获取连接,使用它,然后将其释放回池中。池为您管理连接。
https://stackoverflow.com/questions/8487713
复制相似问题