Consider the following code snippet:
public void getUsers() {
CachedRowSet rowSet = new CachedRowSetImpl();
......... /* Initialize the rowset */
String query = "SELECT user_id FROM users";
rowSet.setCommand(query);
rowSet.execute();
......... /* Do some job */
}
Here the CachedRowSet
object is used locally in a method. Do I need to manually close it here or the contents it holds will be grabage collected automatically when the method finishes?
from: http://docs.oracle.com/javase/1.5.0/docs/api/javax/sql/rowset/CachedRowSet.html
that means there is no connection issue to close so u can leave it
but i think its good practice to always close what you open and not leave it to the GC which you usually don't touch or tell when to run.
given a large enough server with many requests, if it causes open file descriptors it can eventually be an issue. making sure resources are closed is always best