private void reInitState() throws SQLException {
    try {
      closeStatementIfNeeded();
    } finally {
      isCancelled = false;
      isQueryClosed = false;
      isLogBeingGenerated = true;
      isOperationComplete = false;
    }
  }
Close statement if needed, and reset the flags.
@throws SQLException
jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java