This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes JDBC and the fly likes How to check if the state of resultset is closed or not.  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to check if the state of resultset is closed or not.  " Watch "How to check if the state of resultset is closed or not.  " New topic
Author

How to check if the state of resultset is closed or not.

Satish Kota
Ranch Hand

Joined: Feb 08, 2006
Posts: 88
Hi all,
Please tell me if there is any function to know if the state of a resultset is closed or not. I want to perform the following operation.

if( ! <function that returns true if the resultset is closed> )
rs.close();

Thanks to all in advance.


SCJP 5.0 77%
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

I dont think if there is any such method which would tell you if it is closed or not, rather you should close the resultset in finally block of code




Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Then you just call rs.close() and catch any SQLExceptions that might occur. You have to catch them anyway, even if you know the ResultSet is not closed yet.

However you really should reorganize your code, as Shailesh says, so there is no question whether it is closed or not.
 
 
subject: How to check if the state of resultset is closed or not.