aspose file tools*
The moose likes JDBC and the fly likes Hunting leaking connections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Hunting leaking connections" Watch "Hunting leaking connections" New topic
Author

Hunting leaking connections

Jussi Taimiaho
Ranch Hand

Joined: Mar 01, 2004
Posts: 40
Hi,

to keep it short, a software running on WebLogic is leaking connections, so I'll need to fix this. The problem is not apparent, so it'll take a bit effort from me. I have a question about one case. Is this kind of structure any way vulnerable to leaking? I think not, but is it?


[ October 20, 2005: Message edited by: Jussi Taimiaho ]
dema rogatkin
Ranch Hand

Joined: Oct 09, 2002
Posts: 294
It looks Ok for me. I do not see any reason to rethrow exception though. Very unlekely but if a close ps throws runtime exception you can miss con.close().


Tough in space?, <a href="http://tjws.sf.net" target="_blank" rel="nofollow">Get J2EE servlet container under 150Kbytes here</a><br />Love your iPod and want it anywhere?<a href="http://mediachest.sf.net" target="_blank" rel="nofollow">Check it here.</a><br /><a href="http://7bee.j2ee.us/book/Generics%20in%20JDK%201.5.html" target="_blank" rel="nofollow">Curious about generic in Java?</a><br /><a href="http://7bee.j2ee.us/bee/index-bee.html" target="_blank" rel="nofollow">Hate ant? Use bee.</a><br /><a href="http://7bee.j2ee.us/addressbook/" target="_blank" rel="nofollow">Need contacts anywhere?</a><br /><a href="http://searchdir.sourceforge.net/" target="_blank" rel="nofollow">How to promote your business with a search engine</a>
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30751
    
156


This is a bit dangerous. You are doing something with an open connection. Here, it is possible to abandon some of the original resources without closing them.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jussi Taimiaho
Ranch Hand

Joined: Mar 01, 2004
Posts: 40
Originally posted by Jeanne Boyarsky:

This is a bit dangerous. You are doing something with an open connection. Here, it is possible to abandon some of the original resources without closing them.


I don't like this kind of structure either, but if I don't find the leak here I ain't going to touch classes using this style, since they are rather longish, and not written by me.

Thanks for the answers,
jussi
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hunting leaking connections