Interface ConnectionProvider

All Known Implementing Classes:
DataSourceConnectionProvider, SpringDataSourceConnectionProvider
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ConnectionProvider
Interface towards a mechanism that provides access to a JDBC Connection.

The returned connection's transactional lifecycle (commit, rollback, and close) is never managed by ConnectionExecutor or any other consumer of this interface; it remains entirely the responsibility of whatever owns the connection on the other end of this provider, such as a container's transaction manager binding it to the current unit of work.

Since:
2.2
Author:
Allard Buijze, John Hendrikx
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a connection, ready for use.
  • Method Details

    • getConnection

      Connection getConnection() throws SQLException
      Returns a connection, ready for use.

      The caller must never commit, roll back, or close the returned connection directly; its lifecycle is managed externally by whatever this provider obtained it from.

      Returns:
      a connection to use, never null
      Throws:
      SQLException - when an error occurs obtaining the connection