Class Pool
- java.lang.Object
-
- io.vertx.reactivex.sqlclient.SqlClient
-
- io.vertx.reactivex.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 Deprecated Methods Modifier and Type Method Description void
close()
Close the pool and release the associated resources.void
close(Handler<AsyncResult<Void>> handler)
Close the pool and release the associated resources.Pool
connectHandler(Handler<SqlConnection> handler)
Deprecated.Pool
connectionProvider(io.reactivex.functions.Function<Context,io.reactivex.Single<SqlConnection>> provider)
Deprecated.Pool
connectionProvider(Function<Context,Future<SqlConnection>> provider)
Deprecated.boolean
equals(Object o)
void
getConnection()
Get a connection from the pool.void
getConnection(Handler<AsyncResult<SqlConnection>> handler)
Get a connection from the pool.Pool
getDelegate()
int
hashCode()
static Pool
newInstance(Pool arg)
static Pool
pool(Vertx vertx, SqlConnectOptions database, PoolOptions options)
Create a connection pool to thedatabase
with the givenoptions
.static Pool
pool(SqlConnectOptions connectOptions)
Likepool(io.vertx.sqlclient.SqlConnectOptions)
with default options.static Pool
pool(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.Completable
rxClose()
Close the pool and release the associated resources.io.reactivex.Single<SqlConnection>
rxGetConnection()
Get a connection from the pool.<T> io.reactivex.Maybe<T>
rxWithConnection(io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function)
Get a connection from the pool and execute the givenfunction
.<T> io.reactivex.Maybe<T>
rxWithConnection(Function<SqlConnection,Future<T>> function)
Get a connection from the pool and execute the givenfunction
.<T> io.reactivex.Maybe<T>
rxWithTransaction(io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function)
Execute the givenfunction
within a transaction.<T> io.reactivex.Maybe<T>
rxWithTransaction(TransactionPropagation txPropagation, io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function)
LikewithTransaction(java.util.function.Function<io.vertx.reactivex.sqlclient.SqlConnection, io.vertx.core.Future<T>>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)
but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.<T> io.reactivex.Maybe<T>
rxWithTransaction(TransactionPropagation txPropagation, Function<SqlConnection,Future<T>> function)
LikewithTransaction(java.util.function.Function<io.vertx.reactivex.sqlclient.SqlConnection, io.vertx.core.Future<T>>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)
but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.<T> io.reactivex.Maybe<T>
rxWithTransaction(Function<SqlConnection,Future<T>> function)
Execute the givenfunction
within a transaction.int
size()
String
toString()
<T> void
withConnection(io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function)
Get a connection from the pool and execute the givenfunction
.<T> void
withConnection(io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function, Handler<AsyncResult<T>> handler)
Get a connection from the pool and execute the givenfunction
.<T> void
withConnection(Function<SqlConnection,Future<T>> function)
Get a connection from the pool and execute the givenfunction
.<T> void
withConnection(Function<SqlConnection,Future<T>> function, Handler<AsyncResult<T>> handler)
Get a connection from the pool and execute the givenfunction
.<T> void
withTransaction(io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function)
Execute the givenfunction
within a transaction.<T> void
withTransaction(io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function, Handler<AsyncResult<T>> handler)
Execute the givenfunction
within a transaction.<T> void
withTransaction(TransactionPropagation txPropagation, io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function)
LikewithTransaction(java.util.function.Function<io.vertx.reactivex.sqlclient.SqlConnection, io.vertx.core.Future<T>>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)
but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.<T> void
withTransaction(TransactionPropagation txPropagation, io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function, Handler<AsyncResult<T>> handler)
LikewithTransaction(java.util.function.Function<io.vertx.reactivex.sqlclient.SqlConnection, io.vertx.core.Future<T>>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)
but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.<T> void
withTransaction(TransactionPropagation txPropagation, Function<SqlConnection,Future<T>> function)
LikewithTransaction(java.util.function.Function<io.vertx.reactivex.sqlclient.SqlConnection, io.vertx.core.Future<T>>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)
but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.<T> void
withTransaction(TransactionPropagation txPropagation, Function<SqlConnection,Future<T>> function, Handler<AsyncResult<T>> handler)
LikewithTransaction(java.util.function.Function<io.vertx.reactivex.sqlclient.SqlConnection, io.vertx.core.Future<T>>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)
but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.<T> void
withTransaction(Function<SqlConnection,Future<T>> function)
Execute the givenfunction
within a transaction.<T> void
withTransaction(Function<SqlConnection,Future<T>> function, Handler<AsyncResult<T>> handler)
Execute the givenfunction
within a transaction.-
Methods inherited from class io.vertx.reactivex.sqlclient.SqlClient
newInstance, preparedQuery
-
-
-
-
Method Detail
-
getDelegate
public Pool getDelegate()
- Overrides:
getDelegate
in 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 thedatabase
with the givenoptions
.A will be selected among the drivers found on the classpath returning
true
when 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 void getConnection(Handler<AsyncResult<SqlConnection>> handler)
Get a connection from the pool.- Parameters:
handler
- the handler that will get the connection result
-
getConnection
public void getConnection()
Get a connection from the pool.
-
rxGetConnection
public io.reactivex.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:
preparedQuery
in classSqlClient
- Parameters:
sql
-- Returns:
-
withTransaction
public <T> void withTransaction(Function<SqlConnection,Future<T>> function, Handler<AsyncResult<T>> handler)
Execute the givenfunction
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.- Parameters:
function
- the code to executehandler
- the result handler
-
withTransaction
public <T> void withTransaction(Function<SqlConnection,Future<T>> function)
Execute the givenfunction
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.- Parameters:
function
- the code to execute
-
rxWithTransaction
public <T> io.reactivex.Maybe<T> rxWithTransaction(Function<SqlConnection,Future<T>> function)
Execute the givenfunction
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.- Parameters:
function
- the code to execute- Returns:
-
withTransaction
public <T> void withTransaction(io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function, Handler<AsyncResult<T>> handler)
Execute the givenfunction
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.- Parameters:
function
- the code to executehandler
- the result handler
-
withTransaction
public <T> void withTransaction(io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function)
Execute the givenfunction
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.- Parameters:
function
- the code to execute
-
rxWithTransaction
public <T> io.reactivex.Maybe<T> rxWithTransaction(io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function)
Execute the givenfunction
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.- Parameters:
function
- the code to execute- Returns:
-
withTransaction
public <T> void withTransaction(TransactionPropagation txPropagation, Function<SqlConnection,Future<T>> function, Handler<AsyncResult<T>> handler)
LikewithTransaction(java.util.function.Function<io.vertx.reactivex.sqlclient.SqlConnection, io.vertx.core.Future<T>>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)
but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.- Parameters:
txPropagation
-function
-handler
-
-
withTransaction
public <T> void withTransaction(TransactionPropagation txPropagation, Function<SqlConnection,Future<T>> function)
LikewithTransaction(java.util.function.Function<io.vertx.reactivex.sqlclient.SqlConnection, io.vertx.core.Future<T>>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)
but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.- Parameters:
txPropagation
-function
-
-
rxWithTransaction
public <T> io.reactivex.Maybe<T> rxWithTransaction(TransactionPropagation txPropagation, Function<SqlConnection,Future<T>> function)
LikewithTransaction(java.util.function.Function<io.vertx.reactivex.sqlclient.SqlConnection, io.vertx.core.Future<T>>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)
but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.- Parameters:
txPropagation
-function
-- Returns:
-
withTransaction
public <T> void withTransaction(TransactionPropagation txPropagation, io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function, Handler<AsyncResult<T>> handler)
LikewithTransaction(java.util.function.Function<io.vertx.reactivex.sqlclient.SqlConnection, io.vertx.core.Future<T>>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)
but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.- Parameters:
txPropagation
-function
-handler
-
-
withTransaction
public <T> void withTransaction(TransactionPropagation txPropagation, io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function)
LikewithTransaction(java.util.function.Function<io.vertx.reactivex.sqlclient.SqlConnection, io.vertx.core.Future<T>>, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>)
but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.- Parameters:
txPropagation
-function
-
-
rxWithTransaction
public <T> io.reactivex.Maybe<T> rxWithTransaction(TransactionPropagation txPropagation, io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function)
LikewithTransaction(java.util.function.Function<io.vertx.reactivex.sqlclient.SqlConnection, io.vertx.core.Future<T>>, io.vertx.core.Handler<io.vertx.core.AsyncResult<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> void withConnection(Function<SqlConnection,Future<T>> function, Handler<AsyncResult<T>> handler)
Get a connection from the pool and execute the givenfunction
.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.- Parameters:
function
- the code to executehandler
- the result handler
-
withConnection
public <T> void withConnection(Function<SqlConnection,Future<T>> function)
Get a connection from the pool and execute the givenfunction
.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.- Parameters:
function
- the code to execute
-
rxWithConnection
public <T> io.reactivex.Maybe<T> rxWithConnection(Function<SqlConnection,Future<T>> function)
Get a connection from the pool and execute the givenfunction
.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.- Parameters:
function
- the code to execute- Returns:
-
withConnection
public <T> void withConnection(io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function, Handler<AsyncResult<T>> handler)
Get a connection from the pool and execute the givenfunction
.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.- Parameters:
function
- the code to executehandler
- the result handler
-
withConnection
public <T> void withConnection(io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function)
Get a connection from the pool and execute the givenfunction
.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.- Parameters:
function
- the code to execute
-
rxWithConnection
public <T> io.reactivex.Maybe<T> rxWithConnection(io.reactivex.functions.Function<SqlConnection,io.reactivex.Maybe<T>> function)
Get a connection from the pool and execute the givenfunction
.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.- Parameters:
function
- the code to execute- Returns:
-
close
public void close(Handler<AsyncResult<Void>> handler)
Close the pool and release the associated resources.
-
close
public void close()
Close the pool and release the associated resources.
-
rxClose
public io.reactivex.Completable rxClose()
Close the pool and release the associated resources.
-
connectHandler
@Deprecated public Pool connectHandler(Handler<SqlConnection> handler)
Deprecated.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(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
to release the connection to the pool.- Parameters:
handler
- the handler- Returns:
- a reference to this, so the API can be used fluently
-
connectionProvider
@Deprecated public Pool connectionProvider(Function<Context,Future<SqlConnection>> provider)
Deprecated.Replace the default pool connection provider, the newprovider
returns a future connection for a given .A
ConnectionFactory
can be used as connection provider.- Parameters:
provider
- the new connection provider- Returns:
- a reference to this, so the API can be used fluently
-
connectionProvider
@Deprecated public Pool connectionProvider(io.reactivex.functions.Function<Context,io.reactivex.Single<SqlConnection>> provider)
Deprecated.Replace the default pool connection provider, the newprovider
returns a future connection for a given .A
ConnectionFactory
can 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
-
-