-->
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.  [ 13 posts ] 
Author Message
 Post subject: hibernate connection reset after 12 hours?
PostPosted: Mon Jun 28, 2004 3:35 am 
Newbie

Joined: Mon Jun 28, 2004 3:14 am
Posts: 4
I use hibernate+mysql in my application, and tomcat4 as webserver.
I found that when tomcat has been running over 12 hours, access to
database will be unavailable, and a "java.net.SocketException: Connection reset" is thrown.
I wonder if I should define timeout property in my hibernate.cfg.xml, but in fact I even don't know whether this property
exists


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2004 3:38 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
which pool are you using, i think it iq your db that is disconnecting not hibernate...

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2004 3:42 am 
Newbie

Joined: Mon Jun 28, 2004 3:14 am
Posts: 4
I think I use a default pool, following is part of my hibernate.cfg.xml

<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.username">jazz</property>
<property name="hibernate.connection.password">doit</property>
<property name="hibernate.connection.pool.size">1</property>
<property name="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="statement_cache.size">25</property>
<property name="jdbc.fetch_size">50</property>
<property name="jdbc.batch_size">30</property>
<property name="show_sql">false</property>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2004 3:44 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
try proxool with connection check every hour for example

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2004 3:54 am 
Newbie

Joined: Mon Jun 28, 2004 3:14 am
Posts: 4
Is it possible that mysql close the connection after several hours' idle?
For I leave the tomcat open when off duty, and find access is not available
the next morning


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2004 3:57 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
everything is possible ;)

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2004 4:08 am 
Newbie

Joined: Mon Jun 28, 2004 3:14 am
Posts: 4
what is proxool? and would you provide the code to check the connection? I'm really a greenhand to hibernate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2004 4:12 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
read the reference guide, proxool is a connection pool, and checking the connection is done by the pool if you configure it well

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 29, 2004 10:59 pm 
Regular
Regular

Joined: Tue Sep 30, 2003 11:27 am
Posts: 60
Location: Columbus, OH, USA
MySQL is well known to terminate idle connections after 8 hours by default, although you can increase this to a few days in the my.cnf file. From my experience both C3P0 and DBCP are vulnerable to MySQL's drops. I've heard Proxool is a better choice, but I've also heard that Hibernate doesn't read the relevant recheck settings from its configuration file. Does anyone have a working solution to this problem?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 30, 2004 3:59 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
http://www.hibernate.org/hib_docs/api/n ... nment.html

static String C3P0_ACQUIRE_INCREMENT
Number of connections acquired when pool is exhausted
static String C3P0_IDLE_TEST_PERIOD
Idle time before a C3P0 pooled connection is validated
static String C3P0_MAX_SIZE
Maximum size of C3P0 connection pool
static String C3P0_MAX_STATEMENTS
Maximum size of C3P0 statement cache
static String C3P0_MIN_SIZE
Minimum size of C3P0 connection pool
static String C3P0_TIMEOUT
Maximum idle time for C3P0 connection pool
static String C3P0_VALIDATE_CONNECTION
Deprecated. use C3P0_IDLE_TEST_PERIOD


check string values for hibernate.cfg.xml

for proxool you need to specify a configuration file

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 30, 2004 10:13 am 
Regular
Regular

Joined: Tue Sep 30, 2003 11:27 am
Posts: 60
Location: Columbus, OH, USA
I'll try it - thanks Anthony!

Scott


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 30, 2004 12:15 pm 
Beginner
Beginner

Joined: Sat Oct 18, 2003 10:19 am
Posts: 21
Location: Belgium
FYI :

DBCP (jakarta) is another connection pool for tomcat with reconnect feature for mysql
very easy in setup !

_________________
Koen Maes
Leuven, Belgium


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 30, 2004 2:41 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
DBCP is also bugged... be carefull!

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 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.