コード例 #1
0
  /**
   * Execute list of queries. This method is used when using text batch statement and using
   * rewriting (allowMultiQueries || rewriteBatchedStatements). queries will be send to server
   * according to max_allowed_packet size.
   *
   * @param queries list of queryes
   * @param streaming is streaming flag
   * @param isRewritable is rewritable flag
   * @param rewriteOffset rewrite offset
   * @return queryresult
   * @throws QueryException exception
   */
  public AbstractQueryResult executeQuery(
      List<Query> queries, boolean streaming, boolean isRewritable, int rewriteOffset)
      throws QueryException {
    for (Query query : queries) {
      query.validate();
    }
    this.moreResults = false;
    AbstractQueryResult result = null;

    do {
      final SendTextQueryPacket packet =
          new SendTextQueryPacket(queries, isRewritable, rewriteOffset);
      int queriesSend = sendQuery(packet);
      if (result == null) {
        result = result(queries, streaming);
      } else {
        result.addResult(result(queries, streaming));
      }

      if (queries.size() == queriesSend) {
        return result;
      } else {
        queries = queries.subList(queriesSend, queries.size());
      }
    } while (queries.size() > 0);

    return result;
  }
コード例 #2
0
 @Override
 public AbstractQueryResult executePreparedQueryAfterFailover(
     String sql,
     ParameterHolder[] parameters,
     PrepareResult oldPrepareResult,
     MariaDbType[] parameterTypeHeader,
     boolean isStreaming)
     throws QueryException {
   PrepareResult prepareResult = prepare(sql);
   AbstractQueryResult queryResult =
       executePreparedQuery(sql, parameters, prepareResult, parameterTypeHeader, isStreaming);
   queryResult.setFailureObject(prepareResult);
   return queryResult;
 }