Class Pool
- java.lang.Object
 - 
- io.vertx.rxjava3.sqlclient.SqlClient
 - 
- io.vertx.rxjava3.sqlclient.Pool
 
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static TypeArg<Pool>__TYPE_ARG 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description io.reactivex.rxjava3.core.Completableclose()Close the pool and release the associated resources.PoolconnectHandler(Handler<SqlConnection> handler)Set an handler called when the pool has established a connection to the database.PoolconnectionProvider(Function<Context,io.reactivex.rxjava3.core.Single<SqlConnection>> provider)Replace the default pool connection provider, the newproviderreturns a future connection for a given .booleanequals(Object o)io.reactivex.rxjava3.core.Single<SqlConnection>getConnection()Get a connection from the pool.PoolgetDelegate()inthashCode()static PoolnewInstance(Pool arg)static Poolpool(Vertx vertx, SqlConnectOptions database, PoolOptions options)Create a connection pool to thedatabasewith the givenoptions.static Poolpool(SqlConnectOptions connectOptions)Likepool(io.vertx.sqlclient.SqlConnectOptions)with default options.static Poolpool(SqlConnectOptions database, PoolOptions options)Likepool(io.vertx.sqlclient.SqlConnectOptions)with a Vert.x instance created automatically.PreparedQuery<RowSet<Row>>preparedQuery(String sql)A connection is borrowed from the connection pool when the query is executed and then immediately returned to the pool after it completes.Query<RowSet<Row>>query(String sql)A connection is borrowed from the connection pool when the query is executed and then immediately returned to the pool after it completes.io.reactivex.rxjava3.core.CompletablerxClose()Close the pool and release the associated resources.io.reactivex.rxjava3.core.Single<SqlConnection>rxGetConnection()Get a connection from the pool.<T> io.reactivex.rxjava3.core.Maybe<T>rxWithConnection(Function<SqlConnection,io.reactivex.rxjava3.core.Maybe<T>> function)Get a connection from the pool and execute the givenfunction.<T> io.reactivex.rxjava3.core.Maybe<T>rxWithTransaction(TransactionPropagation txPropagation, Function<SqlConnection,io.reactivex.rxjava3.core.Maybe<T>> function)LikewithTransaction(java.util.function.Function<io.vertx.rxjava3.sqlclient.SqlConnection, io.reactivex.rxjava3.core.Maybe<T>>)but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.<T> io.reactivex.rxjava3.core.Maybe<T>rxWithTransaction(Function<SqlConnection,io.reactivex.rxjava3.core.Maybe<T>> function)Execute the givenfunctionwithin a transaction.intsize()StringtoString()<T> io.reactivex.rxjava3.core.Maybe<T>withConnection(Function<SqlConnection,io.reactivex.rxjava3.core.Maybe<T>> function)Get a connection from the pool and execute the givenfunction.<T> io.reactivex.rxjava3.core.Maybe<T>withTransaction(TransactionPropagation txPropagation, Function<SqlConnection,io.reactivex.rxjava3.core.Maybe<T>> function)LikewithTransaction(java.util.function.Function<io.vertx.rxjava3.sqlclient.SqlConnection, io.reactivex.rxjava3.core.Maybe<T>>)but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.<T> io.reactivex.rxjava3.core.Maybe<T>withTransaction(Function<SqlConnection,io.reactivex.rxjava3.core.Maybe<T>> function)Execute the givenfunctionwithin a transaction.- 
Methods inherited from class io.vertx.rxjava3.sqlclient.SqlClient
newInstance, preparedQuery 
 - 
 
 - 
 
- 
- 
Method Detail
- 
getDelegate
public Pool getDelegate()
- Overrides:
 getDelegatein classSqlClient
 
- 
pool
public static Pool pool(SqlConnectOptions connectOptions)
Likepool(io.vertx.sqlclient.SqlConnectOptions)with default options.- Parameters:
 connectOptions-- Returns:
 
 
- 
pool
public static Pool pool(SqlConnectOptions database, PoolOptions options)
Likepool(io.vertx.sqlclient.SqlConnectOptions)with a Vert.x instance created automatically.- Parameters:
 database-options-- Returns:
 
 
- 
pool
public static Pool pool(Vertx vertx, SqlConnectOptions database, PoolOptions options)
Create a connection pool to thedatabasewith the givenoptions.A will be selected among the drivers found on the classpath returning
truewhen applied to the first options of the list.- Parameters:
 vertx- the Vertx instance to be used with the connection pooldatabase- the options used to create the connection pool, such as database hostnameoptions- the options for creating the pool- Returns:
 - the connection pool
 
 
- 
getConnection
public io.reactivex.rxjava3.core.Single<SqlConnection> getConnection()
Get a connection from the pool.- Returns:
 
 
- 
rxGetConnection
public io.reactivex.rxjava3.core.Single<SqlConnection> rxGetConnection()
Get a connection from the pool.- Returns:
 
 
- 
query
public Query<RowSet<Row>> query(String sql)
A connection is borrowed from the connection pool when the query is executed and then immediately returned to the pool after it completes. 
- 
preparedQuery
public PreparedQuery<RowSet<Row>> preparedQuery(String sql)
A connection is borrowed from the connection pool when the query is executed and then immediately returned to the pool after it completes.- Overrides:
 preparedQueryin classSqlClient- Parameters:
 sql-- Returns:
 
 
- 
withTransaction
public <T> io.reactivex.rxjava3.core.Maybe<T> withTransaction(Function<SqlConnection,io.reactivex.rxjava3.core.Maybe<T>> function)
Execute the givenfunctionwithin a transaction.The
functionis 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
handleris given a success result when the function returns a succeeded futures and the transaction commits. Otherwise it is given a failure result.- Parameters:
 function- the code to execute- Returns:
 
 
- 
rxWithTransaction
public <T> io.reactivex.rxjava3.core.Maybe<T> rxWithTransaction(Function<SqlConnection,io.reactivex.rxjava3.core.Maybe<T>> function)
Execute the givenfunctionwithin a transaction.The
functionis 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
handleris given a success result when the function returns a succeeded futures and the transaction commits. Otherwise it is given a failure result.- Parameters:
 function- the code to execute- Returns:
 
 
- 
withTransaction
public <T> io.reactivex.rxjava3.core.Maybe<T> withTransaction(TransactionPropagation txPropagation, Function<SqlConnection,io.reactivex.rxjava3.core.Maybe<T>> function)
LikewithTransaction(java.util.function.Function<io.vertx.rxjava3.sqlclient.SqlConnection, io.reactivex.rxjava3.core.Maybe<T>>)but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.- Parameters:
 txPropagation-function-- Returns:
 
 
- 
rxWithTransaction
public <T> io.reactivex.rxjava3.core.Maybe<T> rxWithTransaction(TransactionPropagation txPropagation, Function<SqlConnection,io.reactivex.rxjava3.core.Maybe<T>> function)
LikewithTransaction(java.util.function.Function<io.vertx.rxjava3.sqlclient.SqlConnection, io.reactivex.rxjava3.core.Maybe<T>>)but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.- Parameters:
 txPropagation-function-- Returns:
 
 
- 
withConnection
public <T> io.reactivex.rxjava3.core.Maybe<T> withConnection(Function<SqlConnection,io.reactivex.rxjava3.core.Maybe<T>> function)
Get a connection from the pool and execute the givenfunction.When the future returned by the
functioncompletes, the connection is returned to the pool.The
handleris given a success result when the function returns a succeeded futures. Otherwise it is given a failure result.- Parameters:
 function- the code to execute- Returns:
 
 
- 
rxWithConnection
public <T> io.reactivex.rxjava3.core.Maybe<T> rxWithConnection(Function<SqlConnection,io.reactivex.rxjava3.core.Maybe<T>> function)
Get a connection from the pool and execute the givenfunction.When the future returned by the
functioncompletes, the connection is returned to the pool.The
handleris given a success result when the function returns a succeeded futures. Otherwise it is given a failure result.- Parameters:
 function- the code to execute- Returns:
 
 
- 
close
public io.reactivex.rxjava3.core.Completable close()
Close the pool and release the associated resources. 
- 
rxClose
public io.reactivex.rxjava3.core.Completable rxClose()
Close the pool and release the associated resources. 
- 
connectHandler
public Pool connectHandler(Handler<SqlConnection> handler)
Set an handler called when the pool has established a connection to the database.This handler allows interactions with the database before the connection is added to the pool.
When the handler has finished, it must call
SqlClient.close()to release the connection to the pool.- Parameters:
 handler- the handler- Returns:
 - a reference to this, so the API can be used fluently
 
 
- 
connectionProvider
public Pool connectionProvider(Function<Context,io.reactivex.rxjava3.core.Single<SqlConnection>> provider)
Replace the default pool connection provider, the newproviderreturns a future connection for a given .A
ConnectionFactorycan be used as connection provider.- 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
 
 
 - 
 
 -