title: getResultSet() "should be called only once per result"
body: <p>According to the <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/sql/Statement.html" rel="nofollow noreferrer">documentation</a> for <code>getResultSet</code> in <code>java.sql.Statement</code>, it says:</p>
  
  <blockquote>
    <p>Retrieves the current result as a ResultSet object. This method should
    be called only once per result.</p>
  </blockquote>
  
  <p>Using some test code, I ran <code>executeQuery()</code> and several calls to <code>getResultSet()</code> and observed that the <code>ResultSet</code> returned pointed to the same object. So I'm guessing it is not returning a different <code>ResultSet</code> which you would need to close individually. But of course this could be unique to my JDBC drivers.</p>
  
  <p>Looking at the <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/sql/ResultSet.html" rel="nofollow noreferrer">documentation</a> for <code>ResultSet</code> it says:</p>
  
  <blockquote>
    <p>A default ResultSet object is not updatable and has a cursor that
    moves forward only. Thus, you can iterate through it only once and
    only from the first row to the last row.</p>
  </blockquote>
  
  <p>This seems like a good reason why it may not be a good idea to call it multiple times as it may lead to some "gotcha" situation. If this was the sole reason, I felt that they could have just said that so I think there might be more to it than just this.</p>
  
  <p>So does anyone know why one shouldn't call <code>getResultSet</code> more than once per result? This <a href="https://stackoverflow.com/questions/9983880/nightmare-java-leak-with-loop-and-jdbc">question</a> is what made me curious in the first place.</p>