io.vertx.sqlclient

## Interface Pool

- All Superinterfaces:
    SqlClient
  All Known Subinterfaces:
    DB2Pool, MySQLPool, PgPool

      public interface Pool
      extends SqlClient

  A pool of SQL connections.
  Author:
    Julien Viet

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `begin(Handler<AsyncResult<Transaction>> handler)` Borrow a connection from the pool and begin a transaction, the underlying connection will be returned to the pool when the transaction ends.
    `void` | `close()` Close the pool and release the associated resources.
    `void` | `getConnection(Handler<AsyncResult<SqlConnection>> handler)` Get a connection from the pool.
    `static Pool` | `pool(SqlConnectOptions connectOptions)` Create a connection pool to the database configured with the given `connectOptions` and default `PoolOptions`
    `static Pool` | `pool(SqlConnectOptions connectOptions, PoolOptions poolOptions)` Create a connection pool to the database configured with the given `connectOptions` and `poolOptions`.
    `static Pool` | `pool(Vertx vertx, SqlConnectOptions connectOptions, PoolOptions poolOptions)` Create a connection pool to the database configured with the given `connectOptions` and `poolOptions`.
    `PreparedQuery<RowSet<Row>>` | `preparedQuery(String sql)` Create a prepared query, one of the `PreparedQuery.execute(io.vertx.sqlclient.Tuple, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` or `PreparedQuery.executeBatch(java.util.List<io.vertx.sqlclient.Tuple>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` methods must be called to execute the query.
    `Query<RowSet<Row>>` | `query(String sql)` Create a query, the `Query.execute(io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` method must be called to execute the query.

- - ### Method Detail

    - #### pool

          static Pool pool(SqlConnectOptions connectOptions)

      Create a connection pool to the database configured with the given `connectOptions` and default `PoolOptions`
      Parameters:
        `connectOptions` - the options used to create the connection pool, such as database hostname
      Returns:
        the connection pool
      Throws:
        `ServiceConfigurationError` - if no compatible drivers are found, or if multiple compatible drivers are found

    - #### pool

          static Pool pool(SqlConnectOptions connectOptions,
                           PoolOptions poolOptions)

      Create a connection pool to the database configured with the given `connectOptions` and `poolOptions`.
      Parameters:
        `connectOptions` - the options used to create the connection pool, such as database hostname
        `poolOptions` - the options for creating the pool
      Returns:
        the connection pool
      Throws:
        `ServiceConfigurationError` - if no compatible drivers are found, or if multiple compatible drivers are found

    - #### pool

          static Pool pool(Vertx vertx,
                           SqlConnectOptions connectOptions,
                           PoolOptions poolOptions)

      Create a connection pool to the database configured with the given `connectOptions` and `poolOptions`.
      Parameters:
        `vertx` - the Vertx instance to be used with the connection pool
        `connectOptions` - the options used to create the connection pool, such as database hostname
        `poolOptions` - the options for creating the pool
      Returns:
        the connection pool
      Throws:
        `ServiceConfigurationError` - if no compatible drivers are found, or if multiple compatible drivers are found

    - #### getConnection

          void getConnection(Handler<AsyncResult<SqlConnection>> handler)

      Get a connection from the pool.
      Parameters:
        `handler` - the handler that will get the connection result

    - #### query

          Query<RowSet<Row>> query(String sql)

      Create a query, the `Query.execute(io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` method must be called to execute the query. A connection is borrowed from the connection pool when the query is executed and then immediately returned to the pool after it completes.
      Specified by:
        `query` in interface `SqlClient`
      Returns:
        the query

    - #### preparedQuery

          PreparedQuery<RowSet<Row>> preparedQuery(String sql)

      Create a prepared query, one of the `PreparedQuery.execute(io.vertx.sqlclient.Tuple, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` or `PreparedQuery.executeBatch(java.util.List<io.vertx.sqlclient.Tuple>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)` methods must be called to execute the query. A connection is borrowed from the connection pool when the query is executed and then immediately returned to the pool after it completes.
      Specified by:
        `preparedQuery` in interface `SqlClient`
      Returns:
        the prepared query

    - #### begin

          void begin(Handler<AsyncResult<Transaction>> handler)

      Borrow a connection from the pool and begin a transaction, the underlying connection will be returned to the pool when the transaction ends.

    - #### close

          void close()

      Close the pool and release the associated resources.
      Specified by:
        `close` in interface `SqlClient`

Copyright © 2021 Eclipse. All rights reserved.