ResultSet.close() is going to release any internal resources used by the ResultSet used to maintain the rows/columns returned from a query..
Calling ResultSet.close() on a closed ResultSet is guaranteed to be a no-op (and is clarified to do so in the JDBC 4.0 spec) We also added an isClosed() method to the ResultSet interface in JDBC 4.0.
Setting the ResultSet object to null will have some benefits depending on the scope of the object
> After given ResultSet is closed (via its .close()
> method), should I write
> rs = null; in order to ensure that it will be
> cleaned? or the close() method sets the ResultSet to
> null itself?
Here is a helpful tip.
Java != C++
Thank you.
Stop worrying about setting things to null. It doesn't do **** all. Just close your resources properly and when your objects go out of scope the garbage collector can do it's thing.
> Setting the ResultSet object to null will have some
> benefits depending on the scope of the object
From someone who I think is a Sun employee of some sort this seems really bad advice.
In 99.99% of cases if people have ResultSet objects that are class variables they are doing something wrong. So there is no scope issue. Close the result set and let it fall out of scope.
Encouraging people to set things to null is a bad, bad, bad, bad idea and is the number of one cause of people reporting problems like "out of cursors exceptions" and "out of connections errors" and the like.