tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Caldarale, Charles R" <Chuck.Caldar...@unisys.com>
Subject RE: Connection Pooling questions
Date Wed, 01 Apr 2009 14:47:17 GMT
> 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


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus
for use only by the intended recipient. If you received this in error, please contact the
sender and delete the e-mail and its attachments from all computers.


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


Mime
View raw message