tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Smith <d...@cornell.edu>
Subject Re: Connection Pooling questions
Date Wed, 01 Apr 2009 15:25:31 GMT
Caldarale, Charles R wrote:
>> From: Shaun Farrugia [mailto:sfarrugia@fry.com]
>> Subject: RE: Connection Pooling questions
>>
>> What happens when the statement isn't closed but the 
>> connection is returned to the pool?
>>     
>
> The connection object your code sees isn't the real connection; it's a wrapper created
by the pool to control access to the real thing.  Likewise, the ResultSet, Statement, PreparedStatement,
etc., objects visible to the webapp are also wrappers around the real objects.  Using these,
the pool knows if the real connection has been cleaned up properly; the pool won't reuse the
connection until it is has returned to an idle state.
>
>   
>> I have some code blocks that don't have a finally block 
>> to close the result set and prepared statement.  If an 
>> exception happens the statement and the result set stay
>> open but the connection gets returned to the pool.
>>     
>
> A brief scan of the code in commons-dbcp indicates that when a Connection.close() is
done, an attempt is made to close the associated Statement and ResultSet objects.  Some experimentation
(which I don't have time for right now) would make me more comfortable with that observation.
>
>  - Chuck
>
>
>   
Just for completeness --

This is assuming the developer didn't unwrap any of the DBCP objects to
access driver specific features. In that case, the original wrapped
objects need to be maintained and closed instead of the unwrapped objects.


--David

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


Mime
View raw message