错误日志中的建议

时间:2014-01-14 10:29:04

标签: java mysql hibernate jdbc

我们正在使用java + hibernate + c3p0。在某些情况下会出现这样的错误:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 70,401,557 milliseconds ago.  The last packet sent successfully to the server was 0 milliseconds ago.

但在其他情况下:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 43,974,672 milliseconds ago.  The last packet sent successfully to the server was 43,974,674 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.

似乎这些是相同的错误。为什么在第二个日志消息建议中打印出来:

 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.

c3p0配置

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> 
    <property name="driverClass" value="${database.driver_class}" /> 
    <property name="jdbcUrl" value="${database.url}" /> 
    <property name="user" value="${database.username}" /> 
    <property name="password" value="${database.password}" /> 
    <property name="maxPoolSize" value="600" /> 
    <property name="maxIdleTime" value="28790" /> 
</bean>

提前致谢!

0 个答案:

没有答案