/** * Batch simple SQL strings and execute the batch where the async result contains a array of Integers. * @param sqlStatements sql statement * @param handler the result handler * @return */ public io.vertx.rxjava.ext.sql.SQLConnection batch(List<String> sqlStatements, Handler<AsyncResult<List<Integer>>> handler) { delegate.batch(sqlStatements, handler); return this; }
@Test public void testBatchCallableStatement() { final SQLConnection conn = connection(); conn.batch(Arrays.asList("CREATE ALIAS println FOR \"io.vertx.ext.jdbc.JDBCBatchTest.proc\""), onSuccess(batchResult -> { assertNotNull(batchResult); assertEquals(1, batchResult.size()); conn.batchCallableWithParams("{ call println() }", Arrays.asList(new JsonArray(), new JsonArray(), new JsonArray()), Arrays.asList(new JsonArray(), new JsonArray(), new JsonArray()), onSuccess(batchResult2 -> { assertNotNull(batchResult2); assertEquals(3, batchResult2.size()); testComplete(); })); })); await(); }
@Test public void testBatchPreparedStatement() { List<String> sql = new ArrayList<>(); sql.add("drop table if exists t"); sql.add("create table t (u BIGINT)"); final SQLConnection conn = connection(); conn.batch(sql, onSuccess(batchResult -> { assertNotNull(batchResult); assertEquals(2, batchResult.size()); List<JsonArray> args = new ArrayList<>(); args.add(new JsonArray().add(System.currentTimeMillis())); args.add(new JsonArray().add(System.currentTimeMillis())); args.add(new JsonArray().add(System.currentTimeMillis())); conn.batchWithParams("insert into t (u) values (?)", args, onSuccess(batchResult2 -> { assertNotNull(batchResult2); assertEquals(3, batchResult2.size()); testComplete(); })); })); await(); }
/** * Batch simple SQL strings and execute the batch where the async result contains a array of Integers. * @param sqlStatements sql statement * @param handler the result handler * @return */ public io.vertx.rxjava.ext.sql.SQLConnection batch(List<String> sqlStatements, Handler<AsyncResult<List<Integer>>> handler) { delegate.batch(sqlStatements, handler); return this; }
@Override public SQLConnection batch(List<String> sqlStatements, Handler<AsyncResult<List<Integer>>> handler) { delegate.batch(sqlStatements, handler); return this; }
@Test public void testBatchStatement() { List<String> sql = new ArrayList<>(); sql.add("drop table if exists t"); sql.add("create table t (u UUID)"); sql.add("insert into t (u) values (random_uuid())"); connection().batch(sql, onSuccess(batchResult -> { assertNotNull(batchResult); assertEquals(3, batchResult.size()); testComplete(); })); await(); }