public List<String> getQueryLog(boolean incremental, int fetchSize)
      throws SQLException, ClosedOrCancelledStatementException {
    checkConnection("getQueryLog");
    if (isCancelled) {
      throw new ClosedOrCancelledStatementException("Method getQueryLog() failed. The " +
          "statement has been closed or cancelled.");
    }

    TFetchResultsResp tFetchResultsResp = null;
    try {
      if (stmtHandle.isPresent()) {
        TFetchResultsReq tFetchResultsReq = new TFetchResultsReq(stmtHandle.get(),
            getFetchOrientation(incremental), fetchSize);
        tFetchResultsReq.setFetchType((short)1);
        tFetchResultsResp = client.FetchResults(tFetchResultsReq);
        Utils.verifySuccessWithInfo(tFetchResultsResp.getStatus());
      } else {
        if (isQueryClosed) {
          throw new ClosedOrCancelledStatementException("Method getQueryLog() failed. The " +
              "statement has been closed or cancelled.");
        } else {
          return Collections.emptyList();
        }
      }
    } catch (SQLException e) {
      throw e;
    } catch (Exception e) {
      throw new SQLException("Error when getting query log", e);
    }

    final List<String> logs = new ArrayList<>();
    try {
      final RowSet rowSet = RowSetFactory.create(tFetchResultsResp.getResults(), connection.getProtocol());
      for (Object[] row : rowSet) {
        logs.add(String.valueOf(row[0]));
      }
    } catch (TException e) {
      throw new SQLException("Error building result set for query log", e);
    }

    return Collections.unmodifiableList(logs);
  }
Get the execution logs of the given SQL statement.
This method is a public API for usage outside of Hive, although it is not part of the
interface java.sql.Statement.
@param incremental indicate getting logs either incrementally or from the beginning,
                   when it is true or false.
@param fetchSize the number of lines to fetch
@return a list of logs. It can be empty if there are no new logs to be retrieved at that time.
@throws SQLException
@throws ClosedOrCancelledStatementException if statement has been cancelled or closed
jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java