-->
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.  [ 2 posts ] 
Author Message
 Post subject: Session and database connections
PostPosted: Thu Sep 28, 2006 3:07 pm 
Newbie

Joined: Thu Jun 15, 2006 8:56 pm
Posts: 2
I'm using Hibernate 3.2.0.cr2 in a standalone application. It is configured to use a mySQL database. I observed the following, with the database shutdown

1. SessionFactory.openSession() returns not null session
2. session.isConnected returns true

The only way I'm notified that the database is down is when I perform session.createQuery... or similar operations (a JDBCConnectionException is thrown). Is there a clean mechanism(non exception throwing) in Hibernate to know if the DB connection is available or not?

Regards,
Lovett.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 7:15 pm 
Regular
Regular

Joined: Tue Sep 26, 2006 11:37 am
Posts: 115
Location: Sacramento, CA
Detecting dead connections is an active process. Generally you use Hibernate with a connection pooling library, for example c3p0.
http://forum.hibernate.org/viewtopic.ph ... 84a270020e

In typical usage you configure c3p0 to test the connections periodically, at checkin at checkout or a combination depending on your application need. When c3p0 test the connection it will run a query on it ("select 1" is popular) or use some db specific tester.

Let me know if this helps. It doesn't answer your questions, put it does suggest that you may need to ask a slightly different one...

Marius


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