Example usage for io.vertx.sqlclient SqlClient preparedBatch

List of usage examples for io.vertx.sqlclient SqlClient preparedBatch

Introduction

In this page you can find the example usage for io.vertx.sqlclient SqlClient preparedBatch.

Prototype

@Fluent
SqlClient preparedBatch(String sql, List<Tuple> batch, Handler<AsyncResult<RowSet<Row>>> handler);

Source Link

Document

Prepare and execute a createBatch.

Usage

From source file:examples.SqlClientExamples.java

License:Apache License

public void queries08(SqlClient client) {

    // Add commands to the batch
    List<Tuple> batch = new ArrayList<>();
    batch.add(Tuple.of("julien", "Julien Viet"));
    batch.add(Tuple.of("emad", "Emad Alblueshi"));

    // Execute the prepared batch
    client.preparedBatch("INSERT INTO USERS (id, name) VALUES ($1, $2)", batch, res -> {
        if (res.succeeded()) {

            // Process rows
            RowSet<Row> rows = res.result();
        } else {/*from w w  w. ja  v a 2  s  . co  m*/
            System.out.println("Batch failed " + res.cause());
        }
    });
}

From source file:examples.SqlClientExamples.java

License:Apache License

public void queries08(SqlClient client) {

    // Add commands to the batch
    List<Tuple> batch = new ArrayList<>();
    batch.add(Tuple.of("julien", "Julien Viet"));
    batch.add(Tuple.of("emad", "Emad Alblueshi"));

    // Execute the prepared batch
    client.preparedBatch("INSERT INTO USERS (id, name) VALUES (?, ?)", batch, res -> {
        if (res.succeeded()) {

            // Process rows
            RowSet<Row> rows = res.result();
        } else {//from w  w w  . j a  v a  2 s.  c  o  m
            System.out.println("Batch failed " + res.cause());
        }
    });
}