com.holonplatform.jdbc

## Interface JdbcConnectionHandler

- All Known Subinterfaces:
    SpringJdbcConnectionHandler

      public interface JdbcConnectionHandler

  JDBC `Connection` handler.

  The connection handler is in charge of getting a `Connection` from a `DataSource` and to release (close) the connection itself.

  The `JdbcConnectionHandler.ConnectionType` is provided, allowing to discern if the connection will be used for connection consumer initialization (`JdbcConnectionHandler.ConnectionType.INIT`) or for the normal JDBC operations.

  Since:
    5.1.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `JdbcConnectionHandler.ConnectionType` Connection type

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static JdbcConnectionHandler` | `create()` Create a default `JdbcConnectionHandler`, which uses `DataSource.getConnection()` to obtain a connection and `Connection.close()` to release the connection.
    `Connection` | `getConnection(DataSource dataSource, JdbcConnectionHandler.ConnectionType connectionType)` Get a `Connection` using given `DataSource`.
    `void` | `releaseConnection(Connection connection, DataSource dataSource, JdbcConnectionHandler.ConnectionType connectionType)` Release given `connection`, performing any connection finalization operation (for example to close the connection).

- - ### Method Detail

    - #### getConnection

          Connection getConnection(DataSource dataSource,
                                   JdbcConnectionHandler.ConnectionType connectionType)
                            throws SQLException

      Get a `Connection` using given `DataSource`.
      Parameters:
        `dataSource` - The `DataSource` from which to obtain connections
        `connectionType` - Connection type to discern if the connection will be used for initialization or for normal JDBC operations
      Returns:
        A connection, which must be not `null`
      Throws:
        `SQLException` - If an error occurred and the connection cannot be provided

    - #### releaseConnection

          void releaseConnection(Connection connection,
                                 DataSource dataSource,
                                 JdbcConnectionHandler.ConnectionType connectionType)
                          throws SQLException

      Release given `connection`, performing any connection finalization operation (for example to close the connection).
      Parameters:
        `connection` - The connection to release
        `dataSource` - The `DataSource` from which the connection was obtained
        `connectionType` - Connection type to discern if the connection was used for initialization or for normal JDBC operations
      Throws:
        `SQLException` - If an error occurred and the connection cannot be released

    - #### create

          static JdbcConnectionHandler create()

      Create a default `JdbcConnectionHandler`, which uses `DataSource.getConnection()` to obtain a connection and `Connection.close()` to release the connection.
      Returns:
        A default `JdbcConnectionHandler` implementation

Copyright © 2019 The Holon Platform. All rights reserved.