-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: MySQL timeout error, autoReconnect=true
PostPosted: Fri Apr 03, 2009 6:08 am 
Newbie

Joined: Mon Dec 15, 2008 9:25 am
Posts: 6
Hi,

I try to create a webservice in JAVA, using hibernate (last version) and MySQL!

All is OK, but after many hours without activity, MySQL return a connection error...

Quote:
The last packet successfully received from the server was121823 seconds ago.The last packet sent successfully to the server was 121823 seconds 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.


I tried to set 'autoReconnect=true' like this, in hibernate.cfg.xml, but the problem is always hehe...
Code:
<property name="hibernate.connection.url">jdbc:mysql://[IP]:3306/[DB_NAME]?autoReconnect=true</property>


All my hibernate.cfg.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>

   <session-factory>
      <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

      <property name="hibernate.connection.password">[PASS]</property>

      <property name="hibernate.connection.url">jdbc:mysql://[IP]:3306/[DB_NAME]?autoReconnect=true</property>

      <property name="hibernate.connection.username">[USER]</property>
      
      <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

      <mapping class="ch.................


Do you have an idea?

This web service is deployed on an ubuntu server, on toncat 5.5...

Thank's in advance.

++


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 03, 2009 7:06 am 
Beginner
Beginner

Joined: Wed Jan 25, 2006 10:18 am
Posts: 28
Perhaps you're using the built-in connection pool?
If that's the case you should see a warning about it in your log when you start Hibernate ("not for production use").

You can use C3P0 instead, put c3p0-0.9.1.jar on your classpath and add this property:
Code:
<property name="hibernate.connection.provider_class"> org.hibernate.connection.C3P0ConnectionProvider </property>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 03, 2009 7:14 am 
Newbie

Joined: Mon Dec 15, 2008 9:25 am
Posts: 6
OK, thanks, I'll test that!

But nothing other to add? This line is enough?

++


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.