commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Behrens Matt - Grand Rapids <Matt.Behr...@Kohler.Com>
Subject Re: DBCP: Closed connections
Date Wed, 23 Apr 2003 13:26:29 GMT
Jason Lea wrote:

> Are you catching the SQLExecption in your try/catch/finally block?
> If you suspect the connection is no good, you could use 
> pool.invalidateObject(conn).  I guess you need to try and close the 
> connection before you do this to tidy up any other statements/resultsets
> that might be open.
 >
>  From the JavaDocs for invalidateObject():
> "This method should be used when an object that has been borrowed is 
> determined (due to an exception or other problem) to be invalid."

Yeah, I am, but I see two problems with this approach.

1.  It would seem I'd have to keep a reference to the pool accessible to 
everything that can catch an SQLException, so they could invalidate the 
object.  Unless I can somehow grab the pool from the connection (don't 
see a way to do that), or maybe indirectly from the JDBC DriverManager?

2.  I'd have to patch everything that can catch an SQLException, so they 
could invalidate the object.

I guess if I want to keep DBCP virgin, though, this would be the way to go.

Mime
View raw message