Interface DbClient

All Known Implementing Classes:
MongoDbClient

public interface DbClient
Helidon database client.
  • Method Details

    • inTransaction

      <U, T extends Subscribable<U>> T inTransaction(Function<DbTransaction,T> executor)
      Execute database statements in transaction.
      Type Parameters:
      T - statement execution result type, MUST be either a Multi or a Single, as returned by all APIs of DbClient.
      U - the type provided by the result type
      Parameters:
      executor - database statement executor, see DbExecute
      Returns:
      statement execution result
    • execute

      <U, T extends Subscribable<U>> T execute(Function<DbExecute,T> executor)
      Execute database statement.
      Type Parameters:
      T - statement execution result type, MUST be either a Multi or a Single, as returned by all APIs of DbClient
      U - the type provided by the result type
      Parameters:
      executor - database statement executor, see DbExecute
      Returns:
      statement execution result
    • 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 key source that defines the type of this database and is used to load appropriate DbClientProvider from Java Service loader
      Returns:
      a builder pre-configured from the provided config