简体   繁体   English

jdbc4.CommunicationsException-神秘的超时

[英]jdbc4.CommunicationsException - mysterious timeout

Full text of log message: 日志消息的全文:

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.

This is strange to me because that is over 10 hours. 这对我来说很奇怪,因为那要超过10个小时。 My program was happily and successfully running, including communicating with the database, over the previous 10 hours. 在过去的10个小时中,我的程序运行愉快并且成功运行,包括与数据库进行通信。 The best hypothesis I have is that a single connection in the pool was stale but in that case I don't know why this wouldn't be cleaned up automatically or if this exception was related to that operation. 我最好的假设是,池中的单个连接是陈旧的,但在那种情况下,我不知道为什么不会自动清除此连接,或者该异常是否与该操作有关。 How should I handle this? 我该如何处理?

Am using c3p0 connection pool. 我正在使用c3p0连接池。

c3p0 has lots of means of testing Connections and preventing them from timing out or going stale. c3p0有很多测试连接并防止其超时或过时的方法。 the simplest way to solve the particular problem you are seeing would be to simply set the config parameter maxIdleTime to, say, 8 hours (28800 seconds). 解决您所遇到的特定问题的最简单方法是将配置参数maxIdleTime设置为8小时(28800秒)。

but you might want to start testing Connections in general, for example, by setting idleConnectionTest period to something frequent and setting testConnectionOnCheckin to true. 但是您可能通常想开始测试连接,例如,通过将idleConnectionTest周期设置为经常使用并将testConnectionOnCheckin设置为true。 See... 看到...

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM