Package io.vertx.sqlclient.spi
Interface Driver<C extends SqlConnectOptions>
-
- All Known Implementing Classes:
DB2Driver
,MSSQLDriver
,MySQLDriver
,OracleDriver
,PgDriver
public interface Driver<C extends SqlConnectOptions>
An entry point to the Vertx Reactive SQL Client Every driver must implement this interface.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
acceptsOptions(SqlConnectOptions connectOptions)
default int
appendQueryPlaceholder(StringBuilder queryBuilder, int index, int current)
Append a parameter placeholder in thequery
.ConnectionFactory<C>
createConnectionFactory(Vertx vertx, NetClientOptions transportOptions)
Create a connection factory to the givendatabase
.default Pool
createPool(Vertx vertx, java.util.function.Supplier<Future<C>> databases, PoolOptions poolOptions, NetClientOptions transportOptions, Handler<SqlConnection> connectHandler)
Create a connection pool to the database configured with the givenconnectOptions
andpoolOptions
.C
downcast(SqlConnectOptions connectOptions)
Downcast the connect options to the specific driver options.Pool
newPool(Vertx vertx, java.util.function.Supplier<Future<C>> databases, PoolOptions options, NetClientOptions transportOptions, Handler<SqlConnection> connectHandler, io.vertx.core.internal.CloseFuture closeFuture)
Create a connection pool to the database configured with the givenconnectOptions
andpoolOptions
.SqlConnectOptions
parseConnectionUri(String uri)
default io.vertx.sqlclient.internal.SqlConnectionInternal
wrapConnection(io.vertx.core.internal.ContextInternal context, ConnectionFactory<C> factory, io.vertx.sqlclient.internal.Connection conn)
-
-
-
Method Detail
-
createPool
default Pool createPool(Vertx vertx, java.util.function.Supplier<Future<C>> databases, PoolOptions poolOptions, NetClientOptions transportOptions, Handler<SqlConnection> connectHandler)
Create a connection pool to the database configured with the givenconnectOptions
andpoolOptions
.The returned pool will automatically closed when
vertx
is notnull
and is closed or when the creating context is closed (e.g verticle undeployment).- Parameters:
vertx
- the Vertx instance to be used with the connection pool ornull
to create an auto closed Vertx instancedatabases
- the list of databasespoolOptions
- the options for creating the pooltransportOptions
- the options to configure the TCP clientconnectHandler
-- Returns:
- the connection pool
-
newPool
Pool newPool(Vertx vertx, java.util.function.Supplier<Future<C>> databases, PoolOptions options, NetClientOptions transportOptions, Handler<SqlConnection> connectHandler, io.vertx.core.internal.CloseFuture closeFuture)
Create a connection pool to the database configured with the givenconnectOptions
andpoolOptions
.This method is not meant to be used directly by users, instead they should use
createPool(Vertx, Supplier, PoolOptions, NetClientOptions, Handler)
.- Parameters:
vertx
- the Vertx instance to be used with the connection pooldatabases
- the list of databasesoptions
- the options for creating the pooltransportOptions
- the options to configure the TCP clientconnectHandler
- the connect handlercloseFuture
- the close future- Returns:
- the connection pool
-
createConnectionFactory
ConnectionFactory<C> createConnectionFactory(Vertx vertx, NetClientOptions transportOptions)
Create a connection factory to the givendatabase
.- Parameters:
vertx
- the Vertx instancetransportOptions
- the options to configure the TCP client- Returns:
- the connection factory
-
parseConnectionUri
SqlConnectOptions parseConnectionUri(String uri)
- Returns:
true
if the driver accepts theconnectOptions
,false
otherwise
-
acceptsOptions
boolean acceptsOptions(SqlConnectOptions connectOptions)
- Returns:
- true if the driver accepts the
connectOptions
, false otherwise
-
downcast
C downcast(SqlConnectOptions connectOptions)
Downcast the connect options to the specific driver options.- Parameters:
connectOptions
- the options to downcast- Returns:
- the downcasted options
-
appendQueryPlaceholder
default int appendQueryPlaceholder(StringBuilder queryBuilder, int index, int current)
Append a parameter placeholder in thequery
.The index starts at
0
.- When
index == current
indicates it is a new parameter and therefore the same * value should be returned. - When
index < current
indicates the builder wants to reuse a parameter. The implementation can either return the same value to indicate the parameter can be reused or return the next index to use (which is shall be thecurrent
value
- Parameters:
queryBuilder
- the builder to append toindex
- the parameter placeholder index- Returns:
- the index at which the parameter placeholder could be added
- When
-
wrapConnection
default io.vertx.sqlclient.internal.SqlConnectionInternal wrapConnection(io.vertx.core.internal.ContextInternal context, ConnectionFactory<C> factory, io.vertx.sqlclient.internal.Connection conn)
-
-