Example usage for io.vertx.sqlclient Row getInteger

List of usage examples for io.vertx.sqlclient Row getInteger

Introduction

In this page you can find the example usage for io.vertx.sqlclient Row getInteger.

Prototype

Integer getInteger(String name);

Source Link

Document

Get an integer value at pos .

Usage

From source file:examples.MySQLClientExamples.java

public void storedProcedureExample(SqlClient client) {
    client.query("CREATE PROCEDURE multi() BEGIN\n" + "  SELECT 1;\n" + "  SELECT 1;\n"
            + "  INSERT INTO ins VALUES (1);\n" + "  INSERT INTO ins VALUES (2);\n" + "END;", ar1 -> {
                if (ar1.succeeded()) {
                    // create stored procedure success
                    client.query("CALL multi();", ar2 -> {
                        if (ar2.succeeded()) {
                            // handle the result
                            RowSet<Row> result1 = ar2.result();
                            Row row1 = result1.iterator().next();
                            System.out.println("First result: " + row1.getInteger(0));

                            RowSet<Row> result2 = result1.next();
                            Row row2 = result2.iterator().next();
                            System.out.println("Second result: " + row2.getInteger(0));

                            RowSet<Row> result3 = result2.next();
                            System.out.println("Affected rows: " + result3.rowCount());
                        } else {
                            System.out.println("Failure: " + ar2.cause().getMessage());
                        }//w w w .j  ava2 s . c  o  m
                    });
                } else {
                    System.out.println("Failure: " + ar1.cause().getMessage());
                }
            });
}

From source file:examples.PgClientExamples.java

License:Apache License

public void typeMapping01(Pool pool) {
    pool.query("SELECT 1::BIGINT \"VAL\"", ar -> {
        RowSet<Row> rowSet = ar.result();
        Row row = rowSet.iterator().next();

        // Stored as java.lang.Long
        Object value = row.getValue(0);

        // Convert to java.lang.Integer
        Integer intValue = row.getInteger(0);
    });/*from   w  w  w  .  ja  va  2  s  .  c o  m*/
}

From source file:examples.PgClientExamples.java

License:Apache License

public void typeMapping02(Pool pool) {
    pool.query("SELECT 1::BIGINT \"VAL\"", ar -> {
        RowSet<Row> rowSet = ar.result();
        Row row = rowSet.iterator().next();

        // Stored as java.lang.Long
        Object value = row.getValue(0);

        // Convert to java.lang.Integer
        Integer intValue = row.getInteger(0);
    });/*from www .j av a 2s. com*/
}

From source file:examples.PgClientExamples.java

License:Apache License

public void returning(SqlClient client) {
    client.preparedQuery("INSERT INTO color (color_name) VALUES ($1), ($2), ($3) RETURNING color_id",
            Tuple.of("white", "red", "blue"), ar -> {
                if (ar.succeeded()) {
                    RowSet<Row> rows = ar.result();
                    System.out.println(rows.rowCount());
                    for (Row row : rows) {
                        System.out.println("generated key: " + row.getInteger("color_id"));
                    }//  www. jav a2s  .  co m
                } else {
                    System.out.println("Failure: " + ar.cause().getMessage());
                }
            });
}

From source file:examples.SqlClientExamples.java

License:Apache License

public void queries07(Row row) {

    String firstName = row.getString("first_name");
    Boolean male = row.getBoolean("male");
    Integer age = row.getInteger("age");

    // ...//from  ww w  .j ava2  s .c  o  m

}