close, preparedQuery
static Pool pool(SqlConnectOptions connectOptions)
pool(SqlConnectOptions, PoolOptions)
with default options.static Pool pool(SqlConnectOptions database, PoolOptions options)
pool(Vertx, SqlConnectOptions, PoolOptions)
with a Vert.x instance created automatically.static Pool pool(Vertx vertx, SqlConnectOptions database, PoolOptions options)
database
with the given options
.
A Driver
will be selected among the drivers found on the classpath returning
true
when Driver.acceptsOptions(SqlConnectOptions)
applied to the first options
of the list.
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 poolServiceConfigurationError
- if no compatible drivers are found, or if multiple compatible drivers are foundvoid getConnection(Handler<AsyncResult<SqlConnection>> handler)
handler
- the handler that will get the connection resultFuture<SqlConnection> getConnection()
getConnection(Handler)
but returns a Future
of the asynchronous resultQuery<RowSet<Row>> query(String sql)
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.PreparedQuery<RowSet<Row>> preparedQuery(String sql)
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.preparedQuery
in interface SqlClient
default <T> void withTransaction(java.util.function.Function<SqlConnection,Future<T>> function, Handler<AsyncResult<T>> handler)
function
within a transaction.
The function
is passed a client executing all operations within a transaction.
When the future returned by the function
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.
function
- the code to executehandler
- the result handlerdefault <T> Future<T> withTransaction(java.util.function.Function<SqlConnection,Future<T>> function)
withTransaction(Function, Handler)
but returns a Future
of the asynchronous result.default <T> void withTransaction(TransactionPropagation txPropagation, java.util.function.Function<SqlConnection,Future<T>> function, Handler<AsyncResult<T>> handler)
withTransaction(Function, Handler)
but allows for setting the mode, defining how the acquired
connection is managed during the execution of the function.default <T> Future<T> withTransaction(TransactionPropagation txPropagation, java.util.function.Function<SqlConnection,Future<T>> function)
withTransaction(Function)
but allows for setting the mode, defining how the acquired
connection is managed during the execution of the function.default <T> void withConnection(java.util.function.Function<SqlConnection,Future<T>> function, Handler<AsyncResult<T>> handler)
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.
function
- the code to executehandler
- the result handlerdefault <T> Future<T> withConnection(java.util.function.Function<SqlConnection,Future<T>> function)
withConnection(Function, Handler)
but returns a Future
of the asynchronous resultvoid close(Handler<AsyncResult<Void>> handler)
@Deprecated Pool connectHandler(Handler<SqlConnection> handler)
ClientBuilder.withConnectHandler(Handler)
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.
handler
- the handler@Deprecated Pool connectionProvider(java.util.function.Function<Context,Future<SqlConnection>> provider)
ClientBuilder.connectingTo(Supplier)
provider
returns a future connection for a
given Context
.
A ConnectionFactory
can be used as connection provider.
provider
- the new connection providerint size()
Copyright © 2024 Eclipse. All rights reserved.