Will a call to PreparedStatement.executeQuery() always close the ResultSet from the previous executeQuery()?

Dieter Wimberger

A quote from the Java API docs, java.sql.ResultSet:

A ResultSet is automatically closed by the Statement that generated it when that Statement is closed, re-executed, or is used to retrieve the next result from a sequence of multiple results.

I think that this should answer your question. It is recommended to retrieve the results into an abitrary datastructure, but be aware that even if in Java parameters are always passed per value; an object variable is a reference (i.e. can be seen as a pointer to an object) and only that reference will be passed per value, but not the object itself. That's a hint for the case that you suddenly get an exception accessing an object you retrieved with myResultSet.getObject().
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact