code: public void checkCloseOnCompletion(ResultSet resultSet) throws SQLException {
      if (mustCloseOnCompletion
          && !closed
          && results != null
          && resultSet.equals(results.getResultSet())) {
        close();
      }
    }
docs: Check that close on completion is asked, and close if so.
  
  @param resultSet resultSet
  @throws SQLException if close has error