Example usage for io.vertx.mysqlclient MySQLClient LAST_INSERTED_ID

List of usage examples for io.vertx.mysqlclient MySQLClient LAST_INSERTED_ID

Introduction

In this page you can find the example usage for io.vertx.mysqlclient MySQLClient LAST_INSERTED_ID.

Prototype

PropertyKind LAST_INSERTED_ID

To view the source code for io.vertx.mysqlclient MySQLClient LAST_INSERTED_ID.

Click Source Link

Document

SqlResult Property for last_insert_id

Usage

From source file:examples.MySQLClientExamples.java

public void lastInsertId(SqlClient client) {
    client.query("INSERT INTO test(val) VALUES ('v1')", ar -> {
        if (ar.succeeded()) {
            RowSet<Row> rows = ar.result();
            long lastInsertId = rows.property(MySQLClient.LAST_INSERTED_ID);
            System.out.println("Last inserted id is: " + lastInsertId);
        } else {//  www  .  j av  a  2s  .c o  m
            System.out.println("Failure: " + ar.cause().getMessage());
        }
    });
}