This essentially runs the following logic: Statement s = connection.createStatement(); for (Query query : queries) { s.addBatch(query.getSQL(true)); } s.execute(); @see Statement#executeBatch()
Statement s = connection.createStatement(); for (Query query : queries) { s.addBatch(query.getSQL(true)); } s.execute();
234235236237238239240241242243244
@Test public void testBatchSingle() { DSLContext e = DSL.using(new MockConnection(new BatchSingle()), SQLDialect.H2); int[] result = e.batch( e.query("insert into x values(1)"), e.query("insert into x values(2)") ).execute(); assertEquals(2, result.length);
270271272273274275276277278279280
DSLContext e = DSL.using(new MockConnection(new BatchMultiple()), SQLDialect.H2); Query query = e.query("insert into x values(?, ?)", null, null); int[] result = e.batch(query) .bind(1, 2) .bind(3, 4) .execute(); assertEquals(2, result.length);