/** * Executes the given SQL <code>SELECT</code> statement which returns the results of the query as a read stream. * @param sql the SQL to execute. For example <code>SELECT * FROM table ...</code>. * @param params these are the parameters to fill the statement. * @param handler the handler which is called once the operation completes. It will return a <code>SQLRowStream</code>. * @return */ public io.vertx.rxjava.ext.sql.SQLConnection queryStreamWithParams(String sql, JsonArray params, Handler<AsyncResult<io.vertx.rxjava.ext.sql.SQLRowStream>> handler) { delegate.queryStreamWithParams(sql, params, new Handler<AsyncResult<io.vertx.ext.sql.SQLRowStream>>() { public void handle(AsyncResult<io.vertx.ext.sql.SQLRowStream> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.sql.SQLRowStream.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
/** * Executes the given SQL <code>SELECT</code> statement which returns the results of the query as a read stream. * @param sql the SQL to execute. For example <code>SELECT * FROM table ...</code>. * @param params these are the parameters to fill the statement. * @param handler the handler which is called once the operation completes. It will return a <code>SQLRowStream</code>. * @return */ public io.vertx.rxjava.ext.sql.SQLConnection queryStreamWithParams(String sql, JsonArray params, Handler<AsyncResult<io.vertx.rxjava.ext.sql.SQLRowStream>> handler) { delegate.queryStreamWithParams(sql, params, new Handler<AsyncResult<io.vertx.ext.sql.SQLRowStream>>() { public void handle(AsyncResult<io.vertx.ext.sql.SQLRowStream> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.ext.sql.SQLRowStream.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
@Override public SQLConnection queryStreamWithParams(String sql, JsonArray params, Handler<AsyncResult<SQLRowStream>> handler) { delegate.queryStreamWithParams(sql, params, handler); return this; }
public static io.vertx.ext.sql.SQLConnection queryStreamWithParams(io.vertx.ext.sql.SQLConnection j_receiver, java.lang.String sql, java.util.List<Object> params, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.sql.SQLRowStream>> handler) { io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.queryStreamWithParams(sql, params != null ? io.vertx.core.impl.ConversionHelper.toJsonArray(params) : null, handler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.sql.SQLRowStream>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.ext.sql.SQLRowStream> ar) { handler.handle(ar.map(event -> io.vertx.core.impl.ConversionHelper.fromObject(event))); } } : null)); return j_receiver; } public static io.vertx.ext.sql.SQLConnection update(io.vertx.ext.sql.SQLConnection j_receiver, java.lang.String sql, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {
} else { final SQLConnection conn = getConnection.result(); conn.queryStreamWithParams(sql, params, query -> { if (query.failed()) { conn.close(close -> {
@Test public void testStreamWithParams() { String sql = "SELECT ID, FNAME, LNAME FROM select_table WHERE LNAME = ? ORDER BY ID"; final AtomicInteger cnt = new AtomicInteger(0); connection().queryStreamWithParams(sql, new JsonArray().add("doe"), onSuccess(res -> { res.handler(row -> { cnt.incrementAndGet(); }).endHandler(v -> { assertEquals(2, cnt.get()); testComplete(); }).exceptionHandler(t -> { fail(t); }); })); await(); }