Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DriverManagerConnection PoolConnection Error

 
himanshu patel
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everybody,
I am getting one problem in J2EE application.
I am using Oracle OC4j.
I have hundreds of method which opens Connection (JDBC) object and explicitly closes at the end of method inside finally {} block. It works fine for almost all methods. But for some method I am getting following errors messages.
……
DriverManagerConnection PoolConnection not closed, check your code!
(Use -Djdbc.connection.debug=true to find out where the leaked connection was created)
……..
Despite of this error, the method works as expected. I do not understand why this happens when
I am releasing connection object at the end of every method inside finally {} block. And to my surprise I am getting this error only for 1-2 methods. I have used same Connection Handling mechanism for all methods.
Could anyone help me to sort out this problem.
Any suggestion is highly appreciated.
Thanks
Himanshu
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just from a design point of view. Is the calls to Opening and closing the connection done directly in each method, Or do you have some sort of Utility class that it can call a method to open and another call to close.
That way if the connection information needs to change, say for a new DBMS or a different Connection String, you do not have to change it in a hundred places. You can just change it in the Utility class.
Could you be using up your connections that are in the Pool. Like lets say you only have 5 connections in you connection pool, and this method that has the error, is in a chain of 6 method calls as in, meth1 calls meth2 which calls meth3, which calls meth4, which calls meth5, which calls meth6. In this case you are down 6 levels and each level is using up a connection from the connection pool, until you have no more connections.
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic