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 ResultSet closing - regarding 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 "ResultSet closing - regarding" Watch "ResultSet closing - regarding" New topic

ResultSet closing - regarding

PN Kumar
Ranch Hand

Joined: Sep 08, 2001
Posts: 38
I have a situation where in i need to use a set of queries, one after the other, to obtain data from different tables. Is it a must to close the statement and resultSet after each of the query?Won't the resultSet change with the statement(or the query)? Is there any specific advantage of closing the result set each time? The query output would be only one row for each of the queries.
Joe Ess

Joined: Oct 29, 2001
Posts: 9191

It is good form to explicity close all of the JDBC objects when you are done with them. Close them in a "finally" block, so they get closed even in the event of an exception.

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: ResultSet closing - regarding
It's not a secret anymore!