【发布时间】:2013-08-03 09:05:27
【问题描述】:
在我的产品服务器上遇到异常,但它会在几个小时后自动解决。这个问题可能是什么原因
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was234747 milliseconds ago.The last packet sent successfully to the server was 234747 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.
我们已经设置了 autoReconnect=true,从论坛我发现我们需要启用空闲连接测试。请指教
会不会是应用程序中任何未关闭的连接导致这个异常?
我们使用的是Ibatis,下面是Ibatisconfig文件
<transactionManager type="JDBC" commitRequired="true">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="com.mysql.jdbc.Driver" />
<property name="JDBC.ConnectionURL"
value="<URL>?autoReconnect=true" />
<property name="JDBC.Username" value="<username>" />
<property name="JDBC.Password" value="<password>" />
<property name="JDBC.DefaultAutoCommit" value="false" />
<property name="Pool.TimeToWait" value="100" />
<property name="Pool.PingQuery" value="select 1" />
<property name="Pool.PingEnabled" value="true" />
<property name="Pool.PingConnectionsOlderThan" value="300000" />
<property name="Pool.PingConnectionsNotUsedFor" value="300000" />
</dataSource>
</transactionManager>
【问题讨论】:
-
您检查过您的 SQL 服务器日志吗?可能相关的 SO 线程:stackoverflow.com/questions/1511855/… 和 stackoverflow.com/questions/9527459/…