Vert.x。在对 update() 的一次调用中执行多个插入

Vert.x. Execute multiple inserts in a single call to update()

是否可以使用 Vert.x JDBCClient 对象执行多个 SQL insertions/updates?

提前致谢

在 Vert.x 3.3 中,您将获得批处理支持,因此您可以按以下方式进行批处理更新:

List<String> batch = new ArrayList<>();
batch.add("INSERT INTO emp (NAME) VALUES ('JOE')");
batch.add("INSERT INTO emp (NAME) VALUES ('JANE')");

connection.batch(batch, res -> {
  if (res.succeeded()) {
    List<Integer> result = res.result();
  } else {
    // Failed!
  }
});

或者如果你想重用准备好的语句:

List<JsonArray> batch = new ArrayList<>();
batch.add(new JsonArray().add("joe"));
batch.add(new JsonArray().add("jane"));

connection.batchWithParams("INSERT INTO emp (name) VALUES (?)", batch, res -> {
  if (res.succeeded()) {
    List<Integer> result = res.result();
  } else {
    // Failed!
  }
});