ResultSet.isClosed()

Hi I'm working on upgrading a projects code to be compatible with Java 1.6 and this one class that implements the ResultSet interface. I'm a little bit stuck on the new method in the ResultSet interface which is the method isClosed().

What is the best way to check if a ResultSet has been closed? Do I need to implement my own close() method that sets a flag stating if a result set has been closed so I can then check that flag in the new isClosed() method? Or is there already a standard method like checkClosed that is used on connections that I could used to test the result set?

Thanks for any help

[624 byte] By [Newworld20a] at [2007-11-27 9:16:38]
# 1

> What is the best way to check if a ResultSet has been

> closed? Do I need to implement my own close() method

> that sets a flag stating if a result set has been

> closed so I can then check that flag in the new

> isClosed() method?

There's already a close() method in that interface, how is it currently implemented?

hunter9000a at 2007-7-12 22:06:34 > top of Java-index,Java Essentials,Java Programming...
# 2

heh, the person who wrote this code 3 years ago decided not to implement that method.

/**

* This method has not been implemented in the MockResultSet

*/

public void close( ) throws SQLException

{

}

This is part of my struggle as I'm trying to clean up this guys code :)

At the time they must have figured it would never be called so they left it empty :/

Newworld20a at 2007-7-12 22:06:34 > top of Java-index,Java Essentials,Java Programming...
# 3
You never close your ResultSets?!
BigDaddyLoveHandlesa at 2007-7-12 22:06:34 > top of Java-index,Java Essentials,Java Programming...
# 4
haha, that was my exact comment when I saw the code.At some point during this project we must have had a lazy programmer.
Newworld20a at 2007-7-12 22:06:34 > top of Java-index,Java Essentials,Java Programming...
# 5

> heh, the person who wrote this code 3 years ago

> decided not to implement that method.

> > /**

> * This method has not been implemented in the

> MockResultSet

>*/

> public void close( ) throws SQLException

>{

> }

>

>

> This is part of my struggle as I'm trying to clean up

> this guys code :)

>

> At the time they must have figured it would never be

> called so they left it empty :/

As the class name indicates (MockResultSet), it looks to me like this class isn't really like a real ResultSet which keeps a connection to a database which needs to be closed. My guess is that it's just basically a data wrapper, and close() doesn't need to do anything to clean up any resources. So if that's the case, isClosed() could be implemented to simply return the constant true.

warnerjaa at 2007-7-12 22:06:34 > top of Java-index,Java Essentials,Java Programming...
# 6

> haha, that was my exact comment when I saw the code.

>

> At some point during this project we must have had a

> lazy programmer.

I bet in this case (about a MockResultSet implementation), you're probably jumping to an erroneous conclusion. See my previous reply.

warnerjaa at 2007-7-12 22:06:34 > top of Java-index,Java Essentials,Java Programming...