Class Pool
- All Implemented Interfaces:
io.vertx.lang.rx.RxDelegate
- Direct Known Subclasses:
JDBCPool
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanGet a connection from the pool.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(SqlConnectOptions)with default options.static Poolpool(SqlConnectOptions database, PoolOptions options) Likepool(SqlConnectOptions)with a Vert.x instance created automatically.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.A connection is borrowed from the connection pool when the query is executed and then immediately returned to the pool after it completes.Get a connection from the pool.<T> Maybe<T> rxWithConnection(Function<SqlConnection, Maybe<T>> function) Get a connection from the pool and execute the givenfunction.<T> Maybe<T> rxWithTransaction(TransactionPropagation txPropagation, Function<SqlConnection, Maybe<T>> function) LikewithTransaction(Function)but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.<T> Maybe<T> rxWithTransaction(Function<SqlConnection, Maybe<T>> function) Execute the givenfunctionwithin a transaction.intsize()toString()<T> Maybe<T> withConnection(Function<SqlConnection, Maybe<T>> function) Get a connection from the pool and execute the givenfunction.<T> Maybe<T> withTransaction(TransactionPropagation txPropagation, Function<SqlConnection, Maybe<T>> function) LikewithTransaction(Function)but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.<T> Maybe<T> withTransaction(Function<SqlConnection, Maybe<T>> function) Execute the givenfunctionwithin a transaction.Methods inherited from class SqlClient
close, newInstance, preparedQuery, rxClose
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
Pool
-
Pool
-
-
Method Details
-
toString
-
equals
-
hashCode
-
getDelegate
- Specified by:
getDelegatein interfaceio.vertx.lang.rx.RxDelegate- Overrides:
getDelegatein classSqlClient
-
pool
Likepool(SqlConnectOptions)with default options.- Parameters:
connectOptions-- Returns:
-
pool
Likepool(SqlConnectOptions)with a Vert.x instance created automatically.- Parameters:
database-options-- Returns:
-
pool
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
Get a connection from the pool.- Returns:
- a future notified with the
SqlConnection
-
rxGetConnection
Get a connection from the pool.- Returns:
- a future notified with the
SqlConnection
-
query
-
preparedQuery
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
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:
- a future notified with the result
-
rxWithTransaction
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:
- a future notified with the result
-
withTransaction
public <T> Maybe<T> withTransaction(TransactionPropagation txPropagation, Function<SqlConnection, Maybe<T>> function) LikewithTransaction(Function)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> Maybe<T> rxWithTransaction(TransactionPropagation txPropagation, Function<SqlConnection, Maybe<T>> function) LikewithTransaction(Function)but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.- Parameters:
txPropagation-function-- Returns:
-
withConnection
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:
- a future notified with the result
-
rxWithConnection
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:
- a future notified with the result
-
size
public int size()- Returns:
- the current pool size approximation
-
newInstance
-