@Override
  public int getUpdateCount() throws SQLException {
    checkConnection("getUpdateCount");
    /**
     * Poll on the operation status, till the operation is complete. We want to ensure that since a
     * client might end up using executeAsync and then call this to check if the query run is
     * finished.
     */
    long numModifiedRows = -1L;
    TGetOperationStatusResp resp = waitForOperationToComplete();
    if (resp != null) {
      numModifiedRows = resp.getNumModifiedRows();
    }
    if (numModifiedRows == -1L || numModifiedRows > Integer.MAX_VALUE) {
      LOG.warn("Invalid number of updated rows: {}", numModifiedRows);
      return -1;
    }
    return (int) numModifiedRows;
  }
Close statement if needed, and reset the flags.
@throws SQLException
jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java