-->
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.  [ 4 posts ] 
Author Message
 Post subject: check connection ThreadLocalSessionContext blocks thread
PostPosted: Tue Apr 17, 2007 8:47 am 
Newbie

Joined: Tue Jan 02, 2007 6:48 am
Posts: 3
Hi all,

I use hibernate in standalone (swing) application. Application is using contextual sessions and context is configured as ThreadLocalSessionContext. I need to test database connections therefore I wanted to use:

Code:
Session s = factory.getCurrentSession();
Transaction tx = s.beginTransaction();
connectionOK = s.isConnected() && !s.connection().isClosed();
tx.commit();


I am using c3p0 to pool connections. But if network connection is lost, thread that runs this code is blocked on line s.beginTransaction and I have SQLException messages in log comming from c3p0.

Does anyone has a glue what to do or what is the best method to test connection?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 18, 2007 7:49 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
I think in this case, the connection testing should be done by c3p0.
It usually does this. Please read the c3p0 docs, I am not an expert
in this case.

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 19, 2007 4:19 am 
Newbie

Joined: Tue Jan 02, 2007 6:48 am
Posts: 3
Yes, c3p0 tests pooled connections and it has several settinngs to do it. But I haven't found method to propagate such a connection loosing into hibernate layer. Any ideas?


steckemetz wrote:
I think in this case, the connection testing should be done by c3p0.
It usually does this. Please read the c3p0 docs, I am not an expert
in this case.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 11:32 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
c3p0 has some methods like this

Code:
PoolBackedDataSource pooled = (PoolBackedDataSource) ds;
pooled.getLastAcquisitionFailureDefaultUser();


There are some more of these methods.
Maybe you can find a solution here.

_________________
dont forget to rate !


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