File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Statement, ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Statement, ResultSet" Watch "Statement, ResultSet" New topic

Statement, ResultSet

Manuel Paco
Ranch Hand

Joined: Sep 23, 2001
Posts: 58
Do I have to close both Statement and ResultSet
or closing Statement will do?
Sam Moran
Ranch Hand

Joined: Sep 28, 2002
Posts: 86
The reading that I have done on Sun's website shows only closing the connection:

I hope this helps!

We make a living by what we get, we make a life by what we give!
Thomas Hubschman
Ranch Hand

Joined: Sep 25, 2002
Posts: 88
The API reads as follows:

public interface ResultSet

public void close() throws SQLException

Releases this ResultSet object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.
Note: A ResultSet object is automatically closed by the Statement object that generated it when that Statement object is closed, re-executed, or is used to retrieve the next result from a sequence of multiple results. A ResultSet object is also automatically closed when it is garbage collected.
SQLException - if a database access error occurs
[ December 07, 2002: Message edited by: Thomas Hubschman ]

SCJP '02, SCWCD '02, SCJD '08, SCSNB '09, SCEA '10
I agree. Here's the link:
subject: Statement, ResultSet
It's not a secret anymore!