本文整理了Java中org.jdbi.v3.core.Handle.createBatch()
方法的一些代码示例,展示了Handle.createBatch()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Handle.createBatch()
方法的具体详情如下:
包路径:org.jdbi.v3.core.Handle
类名称:Handle
方法名:createBatch
[英]Create a non-prepared (no bound parameters, but different SQL) batch statement.
[中]创建非准备(无绑定参数,但不同SQL)批处理语句。
代码示例来源:origin: jdbi/jdbi
/**
* Execute this script in a batch statement
*
* @return an array of ints which are the results of each statement in the script
*/
public int[] execute() {
final List<String> statements = getStatements();
Batch b = handle.createBatch();
statements.forEach(b::add);
return b.execute();
}
代码示例来源:origin: jdbi/jdbi
@Test
public void testBatchException() {
h.execute(CREATE);
Throwable e = catchThrowable(h.createBatch().add(INSERT_NULL)::execute);
// unfortunately...
assertThat(logger.getRawSql()).containsExactly(CREATE, CREATE, null, null);
assertThat(logger.getTimings()).hasSize(2).allMatch(IS_POSITIVE);
assertThat(logger.getExceptions()).containsExactly((SQLException) e.getCause());
}
代码示例来源:origin: jdbi/jdbi
@Test
public void testBatch() {
h.createBatch().add(CREATE).define("x", "foo").execute();
assertThat(logger.getAttributes())
.hasSize(2)
.allMatch(x -> x.get("x").equals("foo"))
.allMatch(x -> x.size() == 1);
}
代码示例来源:origin: jdbi/jdbi
@Test
public void testBatch() {
h.execute(CREATE);
h.createBatch().add(INSERT).execute();
// unfortunately...
assertThat(logger.getRawSql()).containsExactly(CREATE, CREATE, null, null);
assertThat(logger.getTimings()).hasSize(2).allMatch(IS_POSITIVE);
assertThat(logger.getExceptions()).isEmpty();
}
代码示例来源:origin: jdbi/jdbi
@Test
public void testSimpleBatch() {
// tag::simpleBatch[]
Batch batch = handle.createBatch();
batch.add("INSERT INTO fruit VALUES(0, 'apple')");
batch.add("INSERT INTO fruit VALUES(1, 'banana')");
int[] rowsModified = batch.execute();
// end::simpleBatch[]
assertThat(rowsModified).containsExactly(1, 1);
assertThat(handle.createQuery("SELECT count(1) FROM fruit")
.mapTo(int.class)
.findOnly()
.intValue())
.isEqualTo(2);
}
代码示例来源:origin: jdbi/jdbi
@Test
public void testBasics() {
Handle h = dbRule.openHandle();
Batch b = h.createBatch();
b.add("insert into something (id, name) values (0, 'Keith')");
b.add("insert into something (id, name) values (1, 'Eric')");
b.add("insert into something (id, name) values (2, 'Brian')");
b.execute();
List<Something> r = h.createQuery("select * from something order by id").mapToBean(Something.class).list();
assertThat(r).hasSize(3);
}
代码示例来源:origin: jdbi/jdbi
@Test
public void testSimpleBatch() {
Batch b = dbRule.openHandle().createBatch();
b.add("insert into something (id, name) values (0, 'Keith')");
b.add("insert into something (id, name) values (0, 'Keith')");
assertThatExceptionOfType(UnableToExecuteStatementException.class)
.isThrownBy(b::execute)
.satisfies(e -> assertSuppressions(e.getCause()));
}
代码示例来源:origin: org.jdbi/jdbi3
/**
* Execute this script in a batch statement
*
* @return an array of ints which are the results of each statement in the script
*/
public int[] execute() {
final List<String> statements = getStatements();
Batch b = handle.createBatch();
statements.forEach(b::add);
return b.execute();
}
内容来源于网络,如有侵权,请联系作者删除!