title: The last packet successfully received from the server was 109,253 milliseconds ago
body: <p>I know this question has been asked and answered many times but no solution is working for this.</p>
  
  <p>On production I got error like this "The last packet successfully received from the server was 109,253 milliseconds ago.". So i siwtched to c3p0 and has following confguration in persistence.xml and for testing set the property of mysql in my.cnf as <code>wait_timeout=60</code> and used under settings.</p>
  
  <pre><code>&lt;properties&gt;
              &lt;property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider" /&gt;
              &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" /&gt;
              &lt;property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" /&gt;
              &lt;property name="hibernate.show_sql" value="true"&gt;&lt;/property&gt;
              &lt;property name="hibernate.connection.url" value="jdbc:mysql://localhost/Test"/&gt;
              &lt;property name="hibernate.connection.user" value="****" /&gt;
              &lt;property name="hibernate.connection.password" value="***" /&gt;
              &lt;property name="hibernate.hbm2ddl.auto" value="update" /&gt;
              &lt;property name="hibernate.hibernate.auto_close_session" value="true" /&gt;
  
              &lt;property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider"/&gt; 
              &lt;property name="hibernate.c3p0.acquire_increment" value="1"/&gt;
              &lt;property name="hibernate.c3p0.idle_test_period" value="10"/&gt;
              &lt;property name="hibernate.c3p0.min_size" value ="5"/&gt;
              &lt;property name="hibernate.c3p0.max_size" value="20"/&gt;
              &lt;property name="hibernate.c3p0.timeout" value="50"/&gt;
              &lt;property name="hibernate.c3p0.preferredTestQuery" value="select 1"/&gt;
              &lt;property name="hibernate.c3p0.testConnectionOnCheckout" value="true"/&gt;             
      &lt;/properties&gt;
  </code></pre>
  
  <p>even in logs I see </p>
  
  <pre><code>Nov 20, 2014 1:06:35 PM com.mchange.v2.c3p0.C3P0Registry banner
  INFO: Initializing c3p0-0.9.2.1 [built 20-March-2013 10:47:27 +0000; debug? true; trace: 10]
  Nov 20, 2014 1:06:35 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
  INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@1e8ef9ca [ connectionPoolDataSource -&gt; com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@1f5f812 [ acquireIncrement -&gt; 1, acquireRetryAttempts -&gt; 30, acquireRetryDelay -&gt; 1000, autoCommitOnClose -&gt; false, automaticTestTable -&gt; null, breakAfterAcquireFailure -&gt; false, checkoutTimeout -&gt; 0, connectionCustomizerClassName -&gt; null, connectionTesterClassName -&gt; com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -&gt; false, factoryClassLocation -&gt; null, forceIgnoreUnresolvedTransactions -&gt; false, identityToken -&gt; z8kfsx951kn0e3017dmiyd|24ba9ccb, idleConnectionTestPeriod -&gt; 10, initialPoolSize -&gt; 5, maxAdministrativeTaskTime -&gt; 0, maxConnectionAge -&gt; 0, maxIdleTime -&gt; 50, maxIdleTimeExcessConnections -&gt; 0, maxPoolSize -&gt; 20, maxStatements -&gt; 75, maxStatementsPerConnection -&gt; 0, minPoolSize -&gt; 5, nestedDataSource -&gt; com.mchange.v2.c3p0.DriverManagerDataSource@fa4d1db0 [ description -&gt; null, driverClass -&gt; null, factoryClassLocation -&gt; null, identityToken -&gt; z8kfsx951kn0e3017dmiyd|29c3481b, jdbcUrl -&gt; jdbc:mysql://localhost/DAL, properties -&gt; {user=******, password=******} ], preferredTestQuery -&gt; select 1, propertyCycle -&gt; 0, statementCacheNumDeferredCloseThreads -&gt; 0, testConnectionOnCheckin -&gt; false, testConnectionOnCheckout -&gt; true, unreturnedConnectionTimeout -&gt; 0, usesTraditionalReflectiveProxies -&gt; false; userOverrides: {} ], dataSourceName -&gt; null, factoryClassLocation -&gt; null, identityToken -&gt; z8kfsx951kn0e3017dmiyd|126d8fa6, numHelperThreads -&gt; 3 ]
  </code></pre>
  
  <p>but still get same problem. I tried many thing even made hibrenate.properties in class path as i read some where there are some properties like <code>preferredTestQuery</code> whic need to set in properties file so I created a properties file in class path with following properties</p>
  
  <pre><code>hibernate.c3p0.idle_test_period=10
  hibernate.c3p0.min_size=5
  hibernate.c3p0.max_size=75
  hibernate.c3p0.max_statements=75
  hibernate.c3p0.timeout=50
  hibernate.c3p0.preferredTestQuery=select 1
  hibernate.c3p0.testConnectionOnCheckout=true
  </code></pre>
  
  <p>Even properties are loading as in log I can see</p>
  
  <pre><code>org.hibernate.cfg.Environment - HHH000205: Loaded properties from resource hibernate.properties: {hibernate.c3p0.testConnectionOnCheckout=true, hibernate.c3p0.timeout=50, hibernate.c3p0.min_size=5, hibernate.c3p0.max_size=75, hibernate.bytecode.use_reflection_optimizer=false, hibernate.c3p0.preferredTestQuery=select 1, hibernate.c3p0.max_statements=75, hibernate.c3p0.idle_test_period=10
  </code></pre>
  
  <p>but still get same error if I try after one minute . I can't understand what I am missing. Please let me know?</p>