This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JDBC and the fly likes Optimal JDBC connection pooling configuration for tomcat server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Optimal JDBC connection pooling configuration for tomcat server" Watch "Optimal JDBC connection pooling configuration for tomcat server" New topic
Author

Optimal JDBC connection pooling configuration for tomcat server

jay desi
Greenhorn

Joined: Jul 02, 2009
Posts: 27
I have below mentioned configuration for connection pooling on tomcat server 6.0.20:-



Issue here is, that as day passes by, same query that takes about 12-14 seconds to execute in morning takes about 50-70 seconds later in the day...after say 2-3 hours..
And performance degrades further on..I am sure, something is wrong in my connection pooling configuration in server.xml file.

I am not using hibernate or other ORM frameworks.

Pl let me know how do I optimize this configuration.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30789
    
157

Jay,
Are you sure you are closing the connection always and in a finally block? This sounds like a connection leak.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Eduardo Bueno
Ranch Hand

Joined: Jun 04, 2009
Posts: 155
You have crossContext declared as true; are you really using it?

There is nothing wrong in your context. Your problem is not in it.
jay desi
Greenhorn

Joined: Jul 02, 2009
Posts: 27
I use below procedure for closing connections:-

I have a separate class ConnectionUtils that deals with connections, which contains different methods like


Then in my other classes I have methods in following manner:-


So, I do not essentially close connections in finally block, but in try block and set references to null in finally block.
Is this not a good approach?
jay desi
Greenhorn

Joined: Jul 02, 2009
Posts: 27
jeanne/Eduardo .. is the above mentioned way of closing connections appropriate way?
jay desi
Greenhorn

Joined: Jul 02, 2009
Posts: 27
I logged in messages like :-

I added these messages in respective separate "close" methods..And found that
for each query that is executed, these messages were written to log file...So, I guess
connections leak is not taking place...

Is there any other way where we can find if any connections/statements/resultsets are still
open?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Optimal JDBC connection pooling configuration for tomcat server