This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JDBC 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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
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: 8705

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.

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: ResultSet closing - regarding
Similar Threads
[Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt
Problem with UNION query
A[nother] question about tracking down memory leaks
JDBC Program Design Question
some advice please