2 Replies Latest reply on Jan 8, 2015 12:28 PM by mylos78

    MySQL Database connections expiring

    mylos78

      Hi all!

      I have a simple JPA application that performs some Queries on a MySQL database. I have noticed that after a certain amount of time, the Query issues the following exception:

      2015-01-08 12:41:33,268 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-14) The last packet successfully received from the server was 85,597,424 milliseconds ago.  The last packet sent successfully to the server was 85,597,424 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.

      So I have changed the JDBC Connection String to use autoReconnect=true as follows:

      <connection-url>jdbc:mysql://localhost:3306/consolle?autoReconnect=true</connection-url>
      

      However the problem persists. I can see that on Hibernate forums, they recommend to set some properties for the c3p0 pool, however this is not my case as I need to use the application server pool....

      <property name="hibernate.c3p0.min_size" value="3" />
      <property name="hibernate.c3p0.max_size" value="50" />
      <property name="hibernate.c3p0.timeout" value="1800" />
      <property name="hibernate.c3p0.max_statements" value="50" />
      <property name="hibernate.c3p0.idle_test_period" value="28680" />
      

      What other property should I set in my Datasource to avoid the Connection expiration ?

      My Environment: WildFly 8.2.0 , MySQL 5.X

      Thanks!