Example usage for io.vertx.mysqlclient MySQLPool close

List of usage examples for io.vertx.mysqlclient MySQLPool close

Introduction

In this page you can find the example usage for io.vertx.mysqlclient MySQLPool close.

Prototype

void close();

Source Link

Document

Close the pool and release the associated resources.

Usage

From source file:examples.MySQLClientExamples.java

public void gettingStarted() {

    // Connect options
    MySQLConnectOptions connectOptions = new MySQLConnectOptions().setPort(3306).setHost("the-host")
            .setDatabase("the-db").setUser("user").setPassword("secret");

    // Pool options
    PoolOptions poolOptions = new PoolOptions().setMaxSize(5);

    // Create the client pool
    MySQLPool client = MySQLPool.pool(connectOptions, poolOptions);

    // A simple query
    client.query("SELECT * FROM users WHERE id='julien'", ar -> {
        if (ar.succeeded()) {
            RowSet<Row> result = ar.result();
            System.out.println("Got " + result.size() + " rows ");
        } else {/*from w ww  . j  a va 2  s  .  c o m*/
            System.out.println("Failure: " + ar.cause().getMessage());
        }

        // Now close the pool
        client.close();
    });
}