After ResultSet.close()

After given ResultSet is closed (via its .close() method), should I writers = null; in order to ensure that it will be cleaned? or the close() method sets the ResultSet to null itself?
[198 byte] By [Glammya] at [2007-10-2 17:38:55]
# 1
Not normally required. Setting variables to null in the (vain) hope the garbage collector will reclaim the space earlier is not really effective.- Saish
Saisha at 2007-7-13 18:56:15 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

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

lanceaa at 2007-7-13 18:56:15 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
Besides all references created in the method are removed when the method exits so should be dereferenced anyway.
darteda at 2007-7-13 18:56:15 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

> 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.

darteda at 2007-7-13 18:56:15 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

> 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.

darteda at 2007-7-13 18:56:15 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...