Slide 14.30: Processing the result set
  Slide 14.32: Making changes to the database
  Home


Closing the Result Set and Statement Objects


You must explicitly close the ResultSet and Statement objects after you finish using them. This applies to all ResultSet and Statement objects you create when using the Oracle JDBC drivers. The drivers do not have finalizer methods; cleanup routines are performed by the close( ) method of the ResultSet and Statement classes.
If you do not explicitly close your ResultSet and Statement objects, serious memory leaks could occur. You could also run out of cursors in the database.
Closing a result set or statement releases the corresponding cursor in the database.

For example, if your ResultSet object is rset and your Statement object is stmt, close the result set and statement with these lines:
   rset.close( );
   stmt.close( );
When you close a Statement object that a given Connection object creates, the connection itself remains open.