Example usage for io.vertx.mysqlclient MySQLPool pool

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

Introduction

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

Prototype

static MySQLPool pool(MySQLConnectOptions connectOptions, PoolOptions poolOptions) 

Source Link

Document

Create a connection pool to the MySQL server configured with the given connectOptions and poolOptions .

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 av a 2  s  . co m
            System.out.println("Failure: " + ar.cause().getMessage());
        }

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

From source file:examples.MySQLClientExamples.java

public void connecting01() {

    // 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 pooled client
    MySQLPool client = MySQLPool.pool(connectOptions, poolOptions);
}