Example usage for io.vertx.sqlclient PreparedQuery batch

List of usage examples for io.vertx.sqlclient PreparedQuery batch

Introduction

In this page you can find the example usage for io.vertx.sqlclient PreparedQuery batch.

Prototype

@Fluent
PreparedQuery batch(List<Tuple> argsList, Handler<AsyncResult<RowSet<Row>>> handler);

Source Link

Document

Execute a batch.

Usage

From source file:examples.SqlClientExamples.java

License:Apache License

public void usingConnections03(SqlConnection connection) {
    connection.prepare("INSERT INTO USERS (id, name) VALUES ($1, $2)", ar1 -> {
        if (ar1.succeeded()) {
            PreparedQuery prepared = ar1.result();

            // Create a query : bind parameters
            List<Tuple> batch = new ArrayList();

            // Add commands to the createBatch
            batch.add(Tuple.of("julien", "Julien Viet"));
            batch.add(Tuple.of("emad", "Emad Alblueshi"));

            prepared.batch(batch, res -> {
                if (res.succeeded()) {

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

From source file:examples.SqlClientExamples.java

License:Apache License

public void usingConnections03(SqlConnection connection) {
    connection.prepare("INSERT INTO USERS (id, name) VALUES (?, ?)", ar1 -> {
        if (ar1.succeeded()) {
            PreparedQuery prepared = ar1.result();

            // Create a query : bind parameters
            List<Tuple> batch = new ArrayList();

            // Add commands to the createBatch
            batch.add(Tuple.of("julien", "Julien Viet"));
            batch.add(Tuple.of("emad", "Emad Alblueshi"));

            prepared.batch(batch, res -> {
                if (res.succeeded()) {

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