Let's say I get a PreparedStatement from a Connection object, and then later I overwrite the reference with another PreparedStatement. Then, later, I close() the reference. Will the first PreparedStatement (the one I lost the reference to) remain open? Or does some protocol or garbage collection take care of that?
For example:
PreparedStatement ps = connection.prepareStatement(MY_QUERY);
// do stuff
ps.execute();
ps = connection.prepareStatement(MY_OTHER_QUERY);
// do stuff
ps.execute();
ps.close();
Does the first PreparedStatement object, the one used to execute MY_QUERY, remain open?