Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Pool connection leak error

 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Marshal
Posts: 25676
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic