Hi All, I have one basic confirmation, please excuse if you feel it is very basic. Is it ok to close Statement alone? will it intern close ResultSet? or it is mandatory to close ResultSet explicitely? please confirm. I am executing a set of statements inside a Thread continuously where I am not closing ResultSet. I just want to know will it cause a problem. Thanks in advance. Regards, Venkat
I think this snippet from the Statement.close() javadocs will anser your question:
It is generally good practice to release resources as soon as you are finished with them to avoid tying up database resources. ... When a Statement object is closed, its current ResultSet object, if one exists, is also closed.
Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
I agree with Blake in that "in theory" all is fine and dandy. Just beware that he quoted the javadocs. This does not in turn guarantee that an implementation follows this rule. Be safe, and close all your resultsets when you are finished with them.
Explicitly close objects! I went looking to see if this was mentioned in my database (oracle) doc. From the oracle 9i jdbc manual: "If you receive messages that you are running out of cursors or that you are running out of memory, make sure that all your Statement and ResultSet objects are explicitly closed. The Oracle JDBC drivers do not have finalizer methods. They perform cleanup routines by using the close() method of the ResultSet and Statement classes. If you do not explicitly close your result set and statement objects, significant memory leaks can occur. You could also run out of cursors in the database. Closing a result set or statement releases the corresponding cursor in the database. Similarly, you must explicitly close Connection objects to avoid leaking and running out of cursors on the server side. When you close the connection, the JDBC driver closes any open statement objects associated with it, thus releasing the cursor objects on the server side."