tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shawn <javajun...@koyuru.com>
Subject Re: DBCP leak ?
Date Fri, 31 Jan 2003 03:54:47 GMT
On Fri, 2003-01-31 at 12:20, Craig R. McClanahan wrote:


IS IT ESSENTIAL TO DO THIS IN A TRY CLAUSE?  MUCH OF OUR CLOSING ISN'T
AND THAT EXCEPTION ISN'T REARING IT'S UGLY HEAD.  IF AN EXCEPTION WERE
THROWN IN A FINALLY CLAUSE, WOULD WE SEE IT ANYWAY?  STUPID QUESTION (I
WOULD THINK YES BUT IF NOT MAYBE WE ARE LEEKING CONNECTIONS THERE??
MAYBE I JUST WILL DO IT LIKE THAT SINCE BEST PRACTICES ARE JUST THAT.
finally {
>     if (rs != null) {
>       try {
>         rs.close();
>       } catch (SQLException e) {
>         ;
>       }
>       rs = null;
>     }
> 
> 

> >
> > 1) must a local ResultSet be explicitely closed to avoid a leak
> 
> Some JDBC drivers will close the ResultSet for you if you close the
> associated Statement, but it sounds like you're probably not doing that
> either.

In most places yes.  Might drivers also close the ResultSet when using a
preparedStatement.

The ps 	and connection is always closed.  The ResultSet is closed in
most places (and I'll correct where it's not).

I wonder if the Oracle driver wasn't closing it (not that it should be
expected to) and GC wasn't doing it either, hence the leak.
Anyway, thanks for the help.

Will clean up the few rough spots. 

(if you're old
> enough to remember):  "we have met the enemy and they is us".  :-)
> 
> I remember and will try to keep it more in mind.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message