The
problem can occur if you use code like:
try
{
Connection c = // .. aquire connection
performOperation(c);
c.close();
}
catch (SQLException sqe) {
// report error
}
Because that means that your connection will not be closed
if:
1) You don't close it in the catch
clause
2) You get some kind of unchecked exception: i.e:
java.lang.RuntimeException
because any of those will return your function without the "c.close();"
having been run at all.
Instead use code like:
Connection c = null;
try {
c = // .. aquire
connection
performOperation(c);
} catch (SQLException sqle)
{
// report error
}
finally {
if (c != null) {
c.close();
} }
|
- jdbc:leaked connection faisal
- Re: jdbc:leaked connection Johan Fredriksson
- Re: jdbc:leaked connection Patrik Andersson
- Re: jdbc:leaked connection faisal