- java.lang.Object
-
- org.jooq.tools.jdbc.MockConnectionProvider
-
- All Implemented Interfaces:
ConnectionProvider
public class MockConnectionProvider extends Object implements ConnectionProvider
A mock connection provider.This
ConnectionProviderwraps a delegateConnectionProviderand wraps all acquiredConnectionreferences inMockConnection.- Author:
- Lukas Eder
-
-
Constructor Summary
Constructors Constructor Description MockConnectionProvider(ConnectionProvider delegate, MockDataProvider provider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Connectionacquire()Acquire a connection from the connection lifecycle handler.voidrelease(Connection connection)Release a connection to the connection lifecycle handler.
-
-
-
Constructor Detail
-
MockConnectionProvider
public MockConnectionProvider(ConnectionProvider delegate, MockDataProvider provider)
-
-
Method Detail
-
acquire
public final Connection acquire()
Description copied from interface:ConnectionProviderAcquire a connection from the connection lifecycle handler.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:- return the same connection instance
- return the same connection instance for the same thread
- return the same connection instance for the same transaction (e.g. a
javax.transaction.UserTransaction) - return a fresh connection instance every time
jOOQ will guarantee that every acquired connection is released through
ConnectionProvider.release(Connection)exactly once.- Specified by:
acquirein interfaceConnectionProvider- Returns:
- A connection for the current
ExecuteContext. Ifnullis returned (e.g. by NoConnectionProvider), then statements cannot be executed. Attempts to execute statements will result in aDetachedException.
-
release
public final void release(Connection connection)
Description copied from interface:ConnectionProviderRelease a connection to the connection lifecycle handler.jOOQ will guarantee that every acquired connection is released exactly once.
- Specified by:
releasein interfaceConnectionProvider- Parameters:
connection- A connection that was previously obtained fromConnectionProvider.acquire(). This is nevernull.
-
-