0

日志消息全文:

Log Message: An error occurred while grabbing new users com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 44,567,434 milliseconds ago. The last packet sent successfully to the server was 44,567,434 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 server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

这对我来说很奇怪,因为那是超过 10 个小时。在过去的 10 个小时里,我的程序运行愉快且成功,包括与数据库的通信。我最好的假设是池中的单个连接已过时,但在这种情况下,我不知道为什么不会自动清理它,或者这个异常是否与该操作有关。我该如何处理?

我正在使用 c3p0 连接池。

4

1 回答 1

1

c3p0 有很多方法可以测试连接并防止它们超时或过时。解决您所看到的特定问题的最简单方法是将配置参数 maxIdleTime 简单地设置为 8 小时(28800 秒)。

但是您可能希望开始测试一般的连接,例如,通过将 idleConnectionTest 周期设置为频繁设置并将 testConnectionOnCheckin 设置为 true。看...

http://www.mchange.com/projects/c3p0/#configuring_connection_testing

http://www.mchange.com/projects/c3p0/#configuration_properties

于 2012-11-21T23:17:46.977 回答