-
- All Known Implementing Classes:
MongoDbClient
public interface DbClient
Helidon database client.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
DbClient.Builder
Helidon database handler builder.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static DbClient.Builder
builder()
Create Helidon database handler builder.static DbClient.Builder
builder(Config dbConfig)
Create a Helidon database handler builder from configuration.static DbClient.Builder
builder(DbClientProvider source)
Create Helidon database handler builder.static DbClient.Builder
builder(String dbSource)
Create Helidon database handler builder.static DbClient
create(Config config)
Create Helidon database handler builder.String
dbType()
Type of this database provider (such as jdbc:mysql, mongoDB etc.).<U,T extends Subscribable<U>>
Texecute(Function<DbExecute,T> executor)
Execute database statement.<U,T extends Subscribable<U>>
TinTransaction(Function<DbTransaction,T> executor)
Execute database statements in transaction.<C> Single<C>
unwrap(Class<C> cls)
Unwrap database client internals.
-
-
-
Method Detail
-
inTransaction
<U,T extends Subscribable<U>> T inTransaction(Function<DbTransaction,T> executor)
Execute database statements in transaction.
-
execute
<U,T extends Subscribable<U>> T execute(Function<DbExecute,T> executor)
Execute database statement.
-
dbType
String dbType()
Type of this database provider (such as jdbc:mysql, mongoDB etc.).- Returns:
- name of the database provider
-
unwrap
<C> Single<C> unwrap(Class<C> cls)
Unwrap database client internals. Only database connection is supported. Any operations based on this connection are blocking. Reactive support must be implemented in user code.- Type Parameters:
C
- target class to be unwrapped- Parameters:
cls
- target class to be unwrapped- Returns:
- database client internals future matching provided class.
- Throws:
UnsupportedOperationException
- when provided class is not supported
-
create
static DbClient create(Config config)
Create Helidon database handler builder.- Parameters:
config
- name of the configuration node with driver configuration- Returns:
- database handler builder
-
builder
static DbClient.Builder builder()
Create Helidon database handler builder.Database driver is loaded as SPI provider which implements
DbClientProvider
interface. First provider on the class path is selected.- Returns:
- database handler builder
-
builder
static DbClient.Builder builder(DbClientProvider source)
Create Helidon database handler builder.- Parameters:
source
- database driver- Returns:
- database handler builder
-
builder
static DbClient.Builder builder(String dbSource)
Create Helidon database handler builder.Database driver is loaded as SPI provider which implements
DbClientProvider
interface. Provider on the class path with matching name is selected.- Parameters:
dbSource
- SPI provider name- Returns:
- database handler builder
-
builder
static DbClient.Builder builder(Config dbConfig)
Create a Helidon database handler builder from configuration.- Parameters:
dbConfig
- configuration that should contain the keysource
that defines the type of this database and is used to load appropriateDbClientProvider
from Java Service loader- Returns:
- a builder pre-configured from the provided config
-
-