-->
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: Connections Pool being exhausted
PostPosted: Wed Apr 28, 2004 6:02 pm 
Beginner
Beginner

Joined: Thu Feb 26, 2004 6:42 pm
Posts: 24
Hello,
I am facing the problem that when the application has been running for a bit the connection pool gets exhausted sometimes. I was wondering the following

1) I currently have most of my queries (just selects) surrounded by a transaction, is this needed, I started my first example this way and continued with it. I know this is a must for update/insert/deletes but is it needed at all for selects.

2) When due to some exception transaction is not committed/rolled back but the associated session is closed, does the connection associated with the session get returned to the pool or not?

3) The

WARNING: afterTransactionCompletion() was never called

warning that is seen, is that cause for concern or can it be ignored?

4) If any of the above are not causes for connections being lost, what kind of code is normally responsible for the connection pool exhaustion problem.

FYI, all my session.open calls have an associated finally which does
if(sess != null)
sess.close();

Thanks,
Sohil


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 28, 2004 6:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
To answer your questions,

1) Always use transactions even for reads.

2) Sounds like a leak to me. You need to do your best to control resources such as database connections. Follow a good example where a finally block will complete the transacation and close the connection (eg return it to the pool). Maybe your best option is to consider using a TX framework. Spring is a good option.

3) This shows you are NOT closing your connection correctly thus have a resource leak. It should not be ignored.

4) See the examples in the documentation and some of the example code we supply. Alternatively, try out Spring's transaction wrappers.

--David


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 28, 2004 5:33 pm 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
Using a pool like Proxool will help you to discover if you close/dispose your connections properly.

Proxool has a background HouseKeeper threads that does - amongst others - the following:
1/ make sure connections waiting in the pool are still 'working' and discard them if not;
2/ make sure active connections are not active since too long (maximum usage time).

If you do not release your connections properly, feature 2 will close those connections once the maximum lifetime is reached and log a warning message.

This way, you shouldn't reach out of connections, and you will be warned in case of miss-behavior.


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.