0

Getting below exception on my prod server, but it resolves automatically after few hours. What could be the reason for this issue

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.

We have set autoReconnect=true already, From Forums I found that we need enable idle connections test. Please advise

Will it be any unclosed connections in the application causes this exception?

we use Ibatis and below is the Ibatisconfig file

<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>
Selvakumar Ponnusamy
  • 5,363
  • 7
  • 40
  • 78
  • Have you checked your SQL server logs? Possibly relevant SO threads: http://stackoverflow.com/questions/1511855/reproduce-com-mysql-jdbc-exceptions-jdbc4-communicationsexception-with-a-setup-o and http://stackoverflow.com/questions/9527459/com-mysql-jdbc-exceptions-jdbc4-communicationsexception-communications-link-fai – rutter Aug 02 '13 at 07:27

1 Answers1

1

Well, in my project I faced the same issue. We use mysql, and if the connection is idle for 8 hours then db goes unavailable. The solution we used was using C3P0 connection pool. Check about this in here. http://www.mchange.com/projects/c3p0/

chaitanya89
  • 827
  • 3
  • 20
  • 26