public interface DatabaseClient extends ConnectionAccessor
Use one of the static factory methods create(ConnectionFactory)
or obtain a builder()
to create an instance.
Usage example:
ConnectionFactory factory = … DatabaseClient client = DatabaseClient.create(factory); Mono<Actor> actor = client.sql("select first_name, last_name from t_actor") .map(row -> new Actor(row.get("first_name, String.class"), row.get("last_name, String.class"))) .first();
Modifier and Type | Interface and Description |
---|---|
static interface |
DatabaseClient.Builder
A mutable builder for creating a
DatabaseClient . |
static interface |
DatabaseClient.GenericExecuteSpec
Contract for specifying an SQL call along with options leading to the execution.
|
Modifier and Type | Method and Description |
---|---|
static DatabaseClient.Builder |
builder()
Obtain a
DatabaseClient builder. |
static DatabaseClient |
create(ConnectionFactory factory)
Create a
DatabaseClient that will use the provided ConnectionFactory . |
ConnectionFactory |
getConnectionFactory()
Return the
ConnectionFactory that this client uses. |
DatabaseClient.GenericExecuteSpec |
sql(String sql)
Specify a static
sql statement to run. |
DatabaseClient.GenericExecuteSpec |
sql(Supplier<String> sqlSupplier)
Specify a
SQL supplier that provides SQL to run. |
inConnection, inConnectionMany
ConnectionFactory getConnectionFactory()
ConnectionFactory
that this client uses.DatabaseClient.GenericExecuteSpec sql(String sql)
sql
statement to run. Contract for specifying a
SQL call along with options leading to the execution. The SQL string can
contain either native parameter bind markers or named parameters (e.g.
:foo, :bar) when NamedParameterExpander
is enabled.sql
- the SQL statementDatabaseClient.GenericExecuteSpec
NamedParameterExpander
,
DatabaseClient.Builder.namedParameters(boolean)
DatabaseClient.GenericExecuteSpec sql(Supplier<String> sqlSupplier)
SQL supplier
that provides SQL to run.
Contract for specifying an SQL call along with options leading to
the execution. The SQL string can contain either native parameter
bind markers or named parameters (e.g. :foo, :bar) when
NamedParameterExpander
is enabled.
Accepts PreparedOperation
as SQL and binding Supplier
sqlSupplier
- a supplier for the SQL statementDatabaseClient.GenericExecuteSpec
NamedParameterExpander
,
DatabaseClient.Builder.namedParameters(boolean)
,
PreparedOperation
static DatabaseClient create(ConnectionFactory factory)
DatabaseClient
that will use the provided ConnectionFactory
.factory
- the ConnectionFactory
to use for obtaining connectionsDatabaseClient
. Guaranteed to be not null
.static DatabaseClient.Builder builder()
DatabaseClient
builder.