Example usage for io.vertx.sqlclient Tuple of

List of usage examples for io.vertx.sqlclient Tuple of

Introduction

In this page you can find the example usage for io.vertx.sqlclient Tuple of.

Prototype

@GenIgnore
static Tuple of(Object elt1, Object... elts) 

Source Link

Document

Create a tuple of an arbitrary number of elements.

Usage

From source file:examples.PgClientExamples.java

License:Apache License

public void customType02Example(SqlClient client) {
    client.preparedQuery("INSERT INTO address_book (id, address) VALUES ($1, $2)",
            Tuple.of(3, "('Anytown', 'Second Ave', false)"), ar -> {
                if (ar.succeeded()) {
                    RowSet<Row> rows = ar.result();
                    System.out.println(rows.rowCount());
                } else {
                    System.out.println("Failure: " + ar.cause().getMessage());
                }/*from www . j  a  v a 2s  .c  o m*/
            });
}

From source file:examples.PgClientExamples.java

License:Apache License

public void tsQuery01Example(SqlClient client) {
    client.preparedQuery("SELECT to_tsvector( $1 ) @@ to_tsquery( $2 )",
            Tuple.of("fat cats ate fat rats", "fat & rat"), ar -> {
                if (ar.succeeded()) {
                    RowSet<Row> rows = ar.result();
                    for (Row row : rows) {
                        System.out.println("Match : " + row.getBoolean(0));
                    }/*from  ww  w  . j av a  2  s .co  m*/
                } else {
                    System.out.println("Failure: " + ar.cause().getMessage());
                }
            });
}

From source file:examples.PgClientExamples.java

License:Apache License

public void tsQuery02Example(SqlClient client) {
    client.preparedQuery("SELECT to_tsvector( $1 ), to_tsquery( $2 )",
            Tuple.of("fat cats ate fat rats", "fat & rat"), ar -> {
                if (ar.succeeded()) {
                    RowSet<Row> rows = ar.result();
                    for (Row row : rows) {
                        System.out.println("Vector : " + row.getString(0) + ", query : " + row.getString(1));
                    }/* w ww.j a  va  2  s  . c  o  m*/
                } else {
                    System.out.println("Failure: " + ar.cause().getMessage());
                }
            });
}

From source file:examples.SqlClientExamples.java

License:Apache License

public void queries04(SqlClient client) {
    client.preparedQuery("INSERT INTO users (first_name, last_name) VALUES ($1, $2)",
            Tuple.of("Julien", "Viet"), ar -> {
                if (ar.succeeded()) {
                    RowSet<Row> rows = ar.result();
                    System.out.println(rows.rowCount());
                } else {
                    System.out.println("Failure: " + ar.cause().getMessage());
                }/*from  w  w  w.  j ava  2 s .  c  o  m*/
            });
}

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  www.j a v a 2 s . com
            System.out.println("Batch failed " + res.cause());
        }
    });
}

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 ww w  . jav a 2  s  . com
            });
        }
    });
}

From source file:examples.SqlClientExamples.java

License:Apache License

public void queries04(SqlClient client) {
    client.preparedQuery("INSERT INTO users (first_name, last_name) VALUES (?, ?)", Tuple.of("Julien", "Viet"),
            ar -> {/*from   w ww.  jav a2  s . co m*/
                if (ar.succeeded()) {
                    RowSet<Row> rows = ar.result();
                    System.out.println(rows.rowCount());
                } else {
                    System.out.println("Failure: " + ar.cause().getMessage());
                }
            });
}

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 {/*  ww  w.jav  a2 s  .c om*/
            System.out.println("Batch failed " + res.cause());
        }
    });
}

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  ww .jav a 2s  .  co  m*/
            });
        }
    });
}