All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.oracleclient.impl.commands.OracleCursorFetchCommand Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR2
Show newest version
/*
 * Copyright (c) 2011-2023 Contributors to the Eclipse Foundation
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
 * which is available at https://www.apache.org/licenses/LICENSE-2.0.
 *
 * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
 */

package io.vertx.oracleclient.impl.commands;

import io.vertx.core.Future;
import io.vertx.core.impl.ContextInternal;
import io.vertx.oracleclient.impl.RowReader;
import io.vertx.sqlclient.impl.QueryResultHandler;
import io.vertx.sqlclient.impl.command.ExtendedQueryCommand;
import oracle.jdbc.OracleConnection;

public class OracleCursorFetchCommand extends OracleCommand {

  private final QueryResultHandler resultHandler;
  private final int fetch;
  private final RowReader rowReader;

  private OracleCursorFetchCommand(OracleConnection oracleConnection, ContextInternal connectionContext, ExtendedQueryCommand cmd, RowReader rowReader) {
    super(oracleConnection, connectionContext);
    resultHandler = cmd.resultHandler();
    fetch = cmd.fetch();
    this.rowReader = rowReader;
  }

  public static  OracleCursorFetchCommand create(OracleConnection oracleConnection, ContextInternal connectionContext, ExtendedQueryCommand cmd, RowReader rowReader) {
    return new OracleCursorFetchCommand<>(oracleConnection, connectionContext, cmd, rowReader);
  }

  @Override
  protected Future execute() {
    return rowReader.read(fetch).compose(oracleResponse -> {
      oracleResponse.handle(resultHandler);
      return rowReader.hasMore();
    });
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy