Interface ConnectionProvider

All Known Subinterfaces:
TransactionControl, TransactionManager
All Known Implementing Classes:
DefaultTransactionManager, LitebridgeTransactionManager, Transaction

public interface ConnectionProvider
Provides a mechanism to obtain a managed database connection, typically bound to the scope of a transaction. This interface abstracts the underlying connection management, ensuring proper lifecycle handling of the connection resource.

Implementations of this interface are expected to manage the allocation, reuse, and cleanup of database connections in a manner that aligns with the application's transaction and resource management strategy. Connections obtained through this interface may either participate in transactions or operate in auto-commit mode, depending on the context in which they are used.

  • Method Summary

    Modifier and Type
    Method
    Description
    Provides a transaction-bound managed connection to the underlying database.
  • Method Details

    • connection

      ManagedConnection connection() throws SQLException
      Provides a transaction-bound managed connection to the underlying database.

      This method is typically used to execute database operations within the context of the current transaction (or not, if the connection is in auto-commit mode).

      Transactions themselves (and corresponding Connection lifecycle methods) are managed by a TransactionManager and are not supported by the returned ManagedConnection.

      Returns:
      a ManagedConnection instance representing the database connection
      Throws:
      SQLException - if an error occurs while obtaining the connection