Should an application explicitly close ResultSet objects when using the PreparedStatement cache?

Technote (FAQ)
Problem
Even though the WebSphere® Application Server code will close ResultSet objects before returning the prepared statement objects to the cache, the application code must explicitly close the ResultSet objects.
Cause
WebSphere Application Server is not required to close the ResultSet objects for the application, and while the ResultSet objects eventually do close, it is not done immediately. In addition, the JDBC™ driver might not close the ResultSet objects immediately after it receives the ResultSet.close() method from the application.

The result can be a lag between the time the application has called close on the preparedStatement object and the time that the ResultSet is actually removed from memory. On systems with a large Statement cache, this can result in a large build-up of resultSet objects at a single instance, which can cause java.lang.OutOfMemoryErrors to be logged in the SystemOut.log or SystemErr.log.
Solution
A J2EE application must explicitly call close on the ResultSet objects to make sure they are removed from memory as soon as possible.











Document Information

Product categories: Software, Application Servers, Distributed Application & Web Servers, WebSphere Application Server, DB Connections/Connection Pooling
Operating system(s): Multi-Platform
Software version: 3.5, 4.0, 5.0, 5.1, 6.0
Software edition: Edition Independent
Reference #: 1155070
IBM Group: Software Group
Modified date: 2004-07-29