code: public void close(boolean closeConnection) throws SQLException {
          if (closeConnection) {
              resultSet.getStatement().getConnection().close();
          } else {
              resultSet.close();
          }
  
          finished = true;
      }
docs: Closes underlying result set and, optionally, the whole connection.
  
  @param closeConnection Close underlying connection also. Be aware of this if
  connection is used somewhere else.
  @throws SQLException