org.springframework.dao.DataAccessException variants for errors.
Use the static factory method 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 | Class and Description |
|---|---|
| public static interface | DatabaseClient.
A mutable builder for creating a |
| public static interface | DatabaseClient.
Contract for specifying an SQL call along with options leading to the execution. |
| Modifier and Type | Method and Description |
|---|---|
| public static DatabaseClient. | |
| public static DatabaseClient | Returns: a newDatabaseClient; never nullthe factory)ConnectionFactory to use for obtaining connectionsCreate a |
| public ConnectionFactory | Returns: the connection factoryGet the |
| public DatabaseClient. | Returns: a newGenericExecuteSpecthe SQL statement sql)Specify a static |
| public DatabaseClient. | Returns: a newGenericExecuteSpeca supplier for the SQL statement sqlSupplier)Specify an SQL supplier that provides SQL to run. |
| builder | back to summary |
|---|---|
| public static DatabaseClient. Obtain a | |
| create | back to summary |
|---|---|
| public static DatabaseClient create(ConnectionFactory factory) Create a
| |
| getConnectionFactory | back to summary |
|---|---|
| public ConnectionFactory getConnectionFactory() Get the
| |
| sql | back to summary |
|---|---|
| public DatabaseClient. Specify a static
| |
| sql | back to summary |
|---|---|
| public DatabaseClient. Specify an 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
Accepts
| |
DatabaseClient.
| Modifier and Type | Method and Description |
|---|---|
| public DatabaseClient. | |
| public DatabaseClient. | |
| public DatabaseClient | |
| public DatabaseClient. | |
| public DatabaseClient. | executeFunction(ExecuteFunction executeFunction)
Configure an |
| public DatabaseClient. | namedParameters(boolean
true to use named parameter expansion;
false to disable named parameter expansionConfigure whether to use named parameter expansion. |
| apply | back to summary |
|---|---|
| public DatabaseClient. Apply a | |
| bindMarkers | back to summary |
|---|---|
| public DatabaseClient. Configure the | |
| build | back to summary |
|---|---|
| public DatabaseClient build() Build the | |
| connectionFactory | back to summary |
|---|---|
| public DatabaseClient. Configure the | |
| executeFunction | back to summary |
|---|---|
| public DatabaseClient. Configure an
| |
| namedParameters | back to summary |
|---|---|
| public DatabaseClient. Configure whether to use named parameter expansion. Defaults to
| |
| Modifier and Type | Method and Description |
|---|---|
| public DatabaseClient. | bind(int
zero based index to bind the parameter to index, Object either a scalar value or a value)io.Bind a non- |
| public DatabaseClient. | bind(String
the name of the parameter name, Object either a scalar value or a value)io.Bind a non- |
| public DatabaseClient. | |
| public DatabaseClient. | |
| public DatabaseClient. | bindProperties(Object
the source object (a JavaBean or record) source)Bind the bean properties or record components from the given source object, registering each as a named parameter. |
| public DatabaseClient. | bindValues(Map<String, ?>
the source map of parameters, with keys as names and
each value either a scalar value or a source)io.Bind the parameter values from the given source map, registering each as a parameter with the map key as name. |
| public FetchSpec | |
| public default DatabaseClient. | |
| public DatabaseClient. | filter(StatementFilterFunction
the filter to be added to the chain filter)Add the given filter to the end of the filter chain. |
| public < the result type R> Flux | |
| public < the result type R> RowsFetchSpec | |
| public < the result type R> RowsFetchSpec | Returns: aRowsFetchSpec for configuration what to fetcha function that maps from mappingFunction)Row and RowMetadata
to the result typeConfigure a result mapping |
| public < the result type R> RowsFetchSpec | Returns: aRowsFetchSpec for configuration what to fetchthe target class (a JavaBean or record) with properties to
map to (bean properties or record components) mappedClass)Configure a row mapper for the given mapped class and enter the execution stage. |
| public < the result type R> RowsFetchSpec | Returns: aRowsFetchSpec for configuration what to fetchthe target class (a database-supported value class) mappedClass)Configure a mapping for values in the first column and enter the execution stage. |
| public Mono |
| bind | back to summary |
|---|---|
| public DatabaseClient. Bind a non-
| |
| bind | back to summary |
|---|---|
| public DatabaseClient. Bind a non-
| |
| bindNull | back to summary |
|---|---|
| public DatabaseClient. Bind a
| |
| bindNull | back to summary |
|---|---|
| public DatabaseClient. Bind a | |
| bindProperties | back to summary |
|---|---|
| public DatabaseClient. Bind the bean properties or record components from the given source object, registering each as a named parameter.
| |
| bindValues | back to summary |
|---|---|
| public DatabaseClient. Bind the parameter values from the given source map, registering each as a parameter with the map key as name.
| |
| fetch | back to summary |
|---|---|
| public FetchSpec Perform the SQL call and retrieve the result by entering the execution stage. | |
| filter | back to summary |
|---|---|
| public default DatabaseClient. Add the given filter to the end of the filter chain. Filter functions are typically used to invoke methods on the Statement before it is executed. For example:
DatabaseClient client = …;
client.sql("SELECT book_id FROM book").filter(statement -> statement.fetchSize(100))
| |
| filter | back to summary |
|---|---|
| public DatabaseClient. Add the given filter to the end of the filter chain. Filter functions are typically used to invoke methods on the Statement before it is executed. For example:
DatabaseClient client = …;
client.sql("SELECT book_id FROM book").filter((statement, next) -> next.execute(statement.fetchSize(100)))
| |
| flatMap | back to summary |
|---|---|
| public <R> Flux Perform the SQL call and apply
| |
| map | back to summary |
|---|---|
| public <R> RowsFetchSpec Configure a result mapping
| |
| map | back to summary |
|---|---|
| public <R> RowsFetchSpec Configure a result mapping
| |
| mapProperties | back to summary |
|---|---|
| public <R> RowsFetchSpec Configure a row mapper for the given mapped class and enter the execution stage.
| |
| mapValue | back to summary |
|---|---|
| public <R> RowsFetchSpec Configure a mapping for values in the first column and enter the execution stage.
| |
| then | back to summary |
|---|---|
| public Mono Perform the SQL call and return a | |