aspose file tools*
The moose likes BEA/Weblogic and the fly likes SQL Server - Connection pool leak Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "SQL Server - Connection pool leak" Watch "SQL Server - Connection pool leak" New topic
Author

SQL Server - Connection pool leak

Blaine Mincey
Greenhorn

Joined: Nov 28, 2000
Posts: 15
Greetings all.
I am currently running Weblogic 8.1 and a SQL Server 2000 database. I am using JNDI to grab a DataSource from my JDBC Connection pool and am using the weblogic.jdbc.mssqlserver4.Driver JDBC Driver. I have stepped through the configuration docs to *ensure* I set everything up correctly. I have also checked to make sure I am closing all connections when I am done with them. But, my connections max out and I am unable to grab any more connections which renders my application useless.
This application (exact code) ran great on Tomcat. The company just wants to migrate to a commercial product.
Any help would be greatly appreciated. Thanks in advance!
Blaine Mincey
blaine_mincey@mindspring.com
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
Hi,
that's strange, we have a commercial app using sqlserver2000 and it works really well. We're using the MSSqldriver from BEA(the non XA one, the second under the driver's list when you're configuring weblogic pool).
Anyway, I believe you should try to configure the advanced options for the pool and tell the container to shrink and also to test the connections. You can do that under the advanced options for connection pools on the console.
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Can you show us some sample JDBC code that handles the closing of Connections? I am convinced this is not a problem with WebLogic.
Blaine Mincey
Greenhorn

Joined: Nov 28, 2000
Posts: 15
Thanks for the replies. Chris, here is a snippet of the code....
I have implemented the DAO pattern so this is a method on the implementation class that I am using....I have the connection as a variable on the class that is initialized as part of the constructor. This is used within the getConnection() method below....This connection is just the basic grab datasource from JNDI which is pointing to a pool, and return the connection to me.

Ok, now the DBUtilities class is simply a class to close statements, connections, etc.....so, it will have a similar method for each type.

[Added code tags for formatting. - CM]
Thanks so much for looking at this....and please, no one be shy about telling me if I did something totally ridiculous.....seriously
Thanks again!
Blaine
[ April 22, 2004: Message edited by: Blaine Mincey ]
[ April 23, 2004: Message edited by: Chris Mathews ]
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Well, it looks like you're trying to close things, but are you?
Where you have code like this are you actually printing out an error message so you can see if something is failing?
catch( SQLException sqle )
{
// error message
}

We do all our closing in the finally block and have the helper class/method catch the exceptions and log them if desired. Only one set of close calls needed.
Blaine Mincey
Greenhorn

Joined: Nov 28, 2000
Posts: 15
Hi Carol. Thanks for the reply. Yeah, the reason I just have comments in the exception block is that I have been doing a LOT of verbose logging, etc. to see what is going on. I did not want everyone to know how crazy this is making me with all of my log statements
Is there any chance that is could be the driver itself? I have been digging through BEA's website to see if anything is posted about this problem but have been unlucky in finding anything. Does anyone know of any problems with the 8.1 release of Weblogic?
Thanks again!
Blaine
[ April 23, 2004: Message edited by: Blaine Mincey ]
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
There are some minor issues with your database cleanup logic. For example, if the close() call to a ResultSet causes a SQL error then the Connection will never be closed. Therfore, all of the close() operations should occur in there own try-catch blocks. However, this shouldn't really be causing you that many problems.
Are you sure that in some area of your code the Connection.close() call is not being forgotten? This is really a common problem and is definitely motivation enough to use a framework like Spring-JDBC to prevent things like this from ever happening.
For completeness, here is how I handle closing database resources on the few occassions that I code plain vanilla JDBC directly (very seldom now):

Sample JDBC code would then be:

Even when doing straight JDBC I used to typically abstract out of the Connection, Statement, and ResultSet stuff from the developer so that they couldn't forget to close resources. This is of course a bit more complicated but ultimately leads to a better solution. It is all unnecessary now I because I just use Spring-JDBC when doing any JDBC code because they have essentially done the same abstraction... only better.
Blaine Mincey
Greenhorn

Joined: Nov 28, 2000
Posts: 15
Hi Chris.
Thanks SO much for your response and pointing out the errors I had made. You are totally correct about handling all of the closing for the various resources together. I modified my DBUtilities class and modelled it after the example you provided and I am no longer experiencing exhausting the connection pool prematurely or holding on the connections...i.e., no more connection leaks.
Having implemented the DAO pattern, it should not be a problem with implementing the Spring Framework and utilizing their JDBC implementation as you suggested. That is the next thing on my list!
But, many, many thanks for assisting me in solving this problem....and helping my coding skills to improve
Blaine
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQL Server - Connection pool leak
 
Similar Threads
I need advice from a guru
Issue Connecting to MS SQL Server using WAS Embedded connectjdbc Driver
JDBC MSSQL 2000 connection pool manager
Checking Connection Pool Size
Connecting to multiple databases using different jdbc drivers