Class Pool

All Implemented Interfaces:
MutinyDelegate
Direct Known Subclasses:
DB2Pool, JDBCPool, MSSQLPool, MySQLPool, OraclePool, PgPool

public class Pool extends SqlClient implements MutinyDelegate
A connection pool which reuses a number of SQL connections.

NOTE: This class has been automatically generated from the original non Mutiny-ified interface using Vert.x codegen.

  • Field Details

    • __TYPE_ARG

      public static final TypeArg<Pool> __TYPE_ARG
  • Constructor Details

    • Pool

      public Pool(io.vertx.sqlclient.Pool delegate)
    • Pool

      public Pool(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.sqlclient.Pool getDelegate()
      Specified by:
      getDelegate in interface MutinyDelegate
      Overrides:
      getDelegate in class SqlClient
      Returns:
      the delegate used by this Mutiny object of generated type
    • toString

      public String toString()
      Overrides:
      toString in class SqlClient
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class SqlClient
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class SqlClient
    • pool

      public static Pool pool(io.vertx.sqlclient.SqlConnectOptions connectOptions)
      Parameters:
      connectOptions -
      Returns:
    • pool

      public static Pool pool(io.vertx.sqlclient.SqlConnectOptions database, io.vertx.sqlclient.PoolOptions options)
      Parameters:
      database -
      options -
      Returns:
    • pool

      public static Pool pool(Vertx vertx, io.vertx.sqlclient.SqlConnectOptions database, io.vertx.sqlclient.PoolOptions options)
      Parameters:
      vertx - the Vertx instance to be used with the connection pool
      database - the options used to create the connection pool, such as database hostname
      options - the options for creating the pool
      Returns:
      the connection pool
    • getConnection

      @CheckReturnValue public io.smallrye.mutiny.Uni<SqlConnection> getConnection()
      Get a connection from the pool.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • getConnectionAndAwait

      public SqlConnection getConnectionAndAwait()
      Blocking variant of getConnection().

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Returns:
      the SqlConnection instance produced by the operation.
    • getConnectionAndForget

      public void getConnectionAndForget()
      Variant of getConnection() that ignores the result of the operation.

      This method subscribes on the result of getConnection(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from getConnection() but you don't need to compose it with other operations.

    • query

      public Query<RowSet<Row>> query(String sql)
      Overrides:
      query in class SqlClient
      Parameters:
      sql -
      Returns:
    • preparedQuery

      public PreparedQuery<RowSet<Row>> preparedQuery(String sql)
      Overrides:
      preparedQuery in class SqlClient
      Parameters:
      sql -
      Returns:
    • withTransaction

      @CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> withTransaction(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Execute the given function within a transaction.

      The function is passed a client executing all operations within a transaction. When the future returned by the function

      • succeeds the transaction commits
      • fails the transaction rollbacks

      The handler is given a success result when the function returns a succeeded futures and the transaction commits. Otherwise it is given a failure result.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      function - the code to execute
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • withTransactionAndAwait

      public <T> T withTransactionAndAwait(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Blocking variant of withTransaction(Function).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      function - the code to execute
      Returns:
      the T instance produced by the operation.
    • withTransactionAndForget

      public <T> void withTransactionAndForget(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Variant of withTransaction(Function) that ignores the result of the operation.

      This method subscribes on the result of withTransaction(Function), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from withTransaction(Function) but you don't need to compose it with other operations.

      Parameters:
      function - the code to execute
    • withTransaction

      @CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> withTransaction(io.vertx.sqlclient.TransactionPropagation txPropagation, Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Like withTransaction(java.util.function.Function<io.vertx.mutiny.sqlclient.SqlConnection, io.smallrye.mutiny.Uni<T>>) but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      txPropagation -
      function -
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • withTransactionAndAwait

      public <T> T withTransactionAndAwait(io.vertx.sqlclient.TransactionPropagation txPropagation, Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Blocking variant of withTransaction(TransactionPropagation,Function).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      txPropagation -
      function -
      Returns:
      the T instance produced by the operation.
    • withTransactionAndForget

      public <T> void withTransactionAndForget(io.vertx.sqlclient.TransactionPropagation txPropagation, Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Variant of withTransaction(TransactionPropagation,Function) that ignores the result of the operation.

      This method subscribes on the result of withTransaction(TransactionPropagation,Function), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from withTransaction(TransactionPropagation,Function) but you don't need to compose it with other operations.

      Parameters:
      txPropagation -
      function -
    • withConnection

      @CheckReturnValue public <T> io.smallrye.mutiny.Uni<T> withConnection(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Get a connection from the pool and execute the given function.

      When the future returned by the function completes, the connection is returned to the pool.

      The handler is given a success result when the function returns a succeeded futures. Otherwise it is given a failure result.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Parameters:
      function - the code to execute
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • withConnectionAndAwait

      public <T> T withConnectionAndAwait(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Blocking variant of withConnection(Function).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      function - the code to execute
      Returns:
      the T instance produced by the operation.
    • withConnectionAndForget

      public <T> void withConnectionAndForget(Function<SqlConnection,io.smallrye.mutiny.Uni<T>> function)
      Variant of withConnection(Function) that ignores the result of the operation.

      This method subscribes on the result of withConnection(Function), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from withConnection(Function) but you don't need to compose it with other operations.

      Parameters:
      function - the code to execute
    • close

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> close()
      Close the pool and release the associated resources.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Overrides:
      close in class SqlClient
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • closeAndAwait

      public Void closeAndAwait()
      Blocking variant of SqlClient.close().

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Overrides:
      closeAndAwait in class SqlClient
      Returns:
      the Void instance produced by the operation.
    • closeAndForget

      public void closeAndForget()
      Variant of SqlClient.close() that ignores the result of the operation.

      This method subscribes on the result of SqlClient.close(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from SqlClient.close() but you don't need to compose it with other operations.

      Overrides:
      closeAndForget in class SqlClient
    • connectHandler

      @Deprecated public Pool connectHandler(Consumer<SqlConnection> handler)
      Deprecated.
      instead use ClientBuilder#withConnectHandler(Handler)
      Parameters:
      handler - the handler
      Returns:
    • connectionProvider

      @Deprecated public Pool connectionProvider(Function<Context,io.smallrye.mutiny.Uni<SqlConnection>> provider)
      Deprecated.
      Parameters:
      provider - the new connection provider
      Returns:
      a reference to this, so the API can be used fluently
    • size

      public int size()
      Returns:
      the current pool size approximation
    • newInstance

      public static Pool newInstance(io.vertx.sqlclient.Pool arg)