public interface JdbcConnectionHandler
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.
| Modifier and Type | Interface and Description |
|---|---|
static class |
JdbcConnectionHandler.ConnectionType
Connection type
|
| 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). |
Connection getConnection(DataSource dataSource, JdbcConnectionHandler.ConnectionType connectionType) throws SQLException
Connection using given DataSource.dataSource - The DataSource from which to obtain connectionsconnectionType - Connection type to discern if the connection will be used for initialization or for normal
JDBC operationsnullSQLException - If an error occurred and the connection cannot be providedvoid releaseConnection(Connection connection, DataSource dataSource, JdbcConnectionHandler.ConnectionType connectionType) throws SQLException
connection, performing any connection finalization operation (for example to close the
connection).connection - The connection to releasedataSource - The DataSource from which the connection was obtainedconnectionType - Connection type to discern if the connection was used for initialization or for normal JDBC
operationsSQLException - If an error occurred and the connection cannot be releasedstatic JdbcConnectionHandler create()
JdbcConnectionHandler, which uses DataSource.getConnection() to obtain a
connection and Connection.close() to release the connection.JdbcConnectionHandler implementationCopyright © 2019 The Holon Platform. All rights reserved.