This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Pool connection leak error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Pool connection leak error" Watch "Pool connection leak error" New topic
Author

Pool connection leak error

Jignesh Gohel
Ranch Hand

Joined: Dec 28, 2004
Posts: 276
Hi,


In my application i am having a two classes which interacts with the database (ie creates the prepared statements & executes the query...etc.)

Now for getting the connection to the database I have made a general class called DTSConnection having a getConnection() & closePreStCon() methods which gets the connection & closes the connection respectively.

Now if do a simple connection then it works fine.
But when i am using connection pooling ,i am getting the following error:

A JDBC pool connection leak was detected.A connection leak occurs when a connection obtained from the pool was not closed explicitly by calling close() & then was disposed by the Garbage collector & returned to the connection pool.

I am providing the code templates which i have used for both the query interactor classes which is related to the connection below....


Also my actual environment where the project is to be depolyed consists of
weblogic server & unix enviroment with jdk1.3.

But my development environment consists of Tomcat 4.1 & jdk 1.4 & Windows.
In my development enviroment i am not obtaining the connections using pooling while in deployemnt environment connection pooling is used.


Both the query interactor classes are as follows:

QueryInteractor class 1




QueryInteractor 2




So please help me to sort out the error And also please tell me what is the reson behind this problem.

What i think is (just a guess )it may be due to the use of getConnection() method in both the classes.But i have closed all the connections afetr getting them...
[ June 13, 2006: Message edited by: Jignesh Gohel ]

Regards,
Jignesh

The Art Of Life Is To Know When To Be Useless And When To Be Useful - CHUANG TZU
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Originally posted by Jignesh Gohel:
But i have closed all the connections afetr getting them...
No, you haven't. Look more closely at your createPreparedStatement method.
Jignesh Gohel
Ranch Hand

Joined: Dec 28, 2004
Posts: 276
Hi Paul thanks for the reply.

Its because after preparing the statement using createPreparedStatement() method i am immediately using either the selectQuery() or updateExecute() method & in both of them i am closing the connections.

And is it valid that we can close the connection after preparing the statement & later on use that prepared statement object after opening the connection once gain???

And please tell me what changes i will have to amke in my code..It would be a great help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pool connection leak error
 
Similar Threads
2 simple questions..
JDBC Connection Pooling issue
Inserting multiple rows at a time in the table?
connection problem
Validation/DB query question