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

Inputs needed writing a tool to resolve Connection leakage problem

 
dumb dumber
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am maintaining and existing application which is inconsistently giving Connection leakage problem. Due to the size of the application its not possible for me to go through all DAO classes and check if all connection/resultsets/statements have been closed properly.

I am thinking of writing a generic code which can analyse methods of a java/class file and see if all connection/resultsets/statements have been closed properly.

I thought of using java.lang.reflect but i think using that i can only get the method signature/params/returns type but getting into the method may not be possible.

Please me know if anyone has any idea or efficient approach of doing this rather than going through the class line by line.
 
dumb dumber
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any takers???
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using Apace DBCP, then try passing "removeAbondend" & "logAbandoned" parameters to the connection string, it will collect all the not closed connection once the time out and logs the method/classes who're culprit.
More info:
http://commons.apache.org/dbcp/configuration.html

Also change your display name, we don't like to call you as a "dumb dumber" ;)
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sagar Rohankar wrote:... "logAbandoned" parameters to the connection string, ... and logs the method/classes who're culprit....
Sagar, thank you for this info. I love it when I learn something new on the ranch. (Also shows that I should read my documents better, doesn't it?)
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome, Jan ! Its just a matter of fact that I personally get stuck for the 15 days configuring the DBCP with MySQL, thats consequently forced me to read the DBCP docs/guide ;)

And I'm learning from your post, too (especially your quite active in DBCP section )
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic