public interface ConnectionProvider
The ConnectionProvider
allows for abstracting the handling of
custom Connection
lifecycles outside of jOOQ, injecting
behaviour into jOOQ's internals. jOOQ will try to acquire a new JDBC
Connection
from the connection provider as early as needed, and will
release it as early as possible.
TransactionProvider
implementations may choose to influence
ConnectionProvider
behaviour, e.g. by acquiring connections upon
TransactionProvider.begin(TransactionContext)
and by releasing
connections only upon TransactionProvider.commit(TransactionContext)
,
or TransactionProvider.rollback(TransactionContext)
.
Modifier and Type | Method and Description |
---|---|
Connection |
acquire()
Acquire a connection from the connection lifecycle handler.
|
void |
release(Connection connection)
Release a connection to the connection lifecycle handler.
|
Connection acquire() throws DataAccessException
This method is called by jOOQ exactly once per execution lifecycle, i.e.
per ExecuteContext
. Implementations may freely chose, whether
subsequent calls to this method:
javax.transaction.UserTransaction
)
jOOQ will guarantee that every acquired connection is released through
release(Connection)
exactly once.
ExecuteContext
.DataAccessException
- If anything went wrong while acquiring a
connectionvoid release(Connection connection) throws DataAccessException
jOOQ will guarantee that every acquired connection is released exactly once.
connection
- A connection that was previously obtained from
acquire()
. This is never null
.DataAccessException
- If anything went wrong while releasing a
connectionCopyright © 2016. All Rights Reserved.