- java.lang.Object
-
- org.jooq.impl.DefaultConnectionProvider
-
- All Implemented Interfaces:
ConnectionProvider
public class DefaultConnectionProvider extends Object implements ConnectionProvider
A default implementation forConnectionProvider
.This implementation just wraps a JDBC
Connection
and provides jOOQ with the same connection for every query. jOOQ will not call any transaction-related methods on the supplied connection. Instead, jOOQ provides you with convenient access to those methods, wrapping any checkedSQLException
into an uncheckedDataAccessException
- Author:
- Aaron Digulla, Lukas Eder
-
-
Constructor Summary
Constructors Constructor Description DefaultConnectionProvider(Connection connection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull Connection
acquire()
Acquire a connection from the connection lifecycle handler.void
commit()
Convenience method to accessConnection.commit()
.protected void
finalize()
boolean
getAutoCommit()
Convenience method to accessConnection.getAutoCommit()
.int
getHoldability()
Convenience method to accessConnection.getHoldability()
.int
getTransactionIsolation()
Convenience method to accessConnection.getTransactionIsolation()
.boolean
isReadOnly()
Convenience method to accessConnection.isReadOnly()
.void
release(Connection released)
Release a connection to the connection lifecycle handler.void
releaseSavepoint(Savepoint savepoint)
Convenience method to accessConnection.releaseSavepoint(Savepoint)
.void
rollback()
Convenience method to accessConnection.rollback()
.void
rollback(Savepoint savepoint)
Convenience method to accessConnection.rollback(Savepoint)
.void
setAutoCommit(boolean autoCommit)
Convenience method to accessConnection.setAutoCommit(boolean)
.void
setConnection(Connection connection)
void
setHoldability(int holdability)
Convenience method to accessConnection.setHoldability(int)
.void
setReadOnly(boolean readOnly)
Convenience method to accessConnection.setReadOnly(boolean)
.@NotNull Savepoint
setSavepoint()
Convenience method to accessConnection.setSavepoint()
.@NotNull Savepoint
setSavepoint(String name)
Convenience method to accessConnection.setSavepoint(String)
.void
setTransactionIsolation(int level)
Convenience method to accessConnection.setTransactionIsolation(int)
.
-
-
-
Constructor Detail
-
DefaultConnectionProvider
public DefaultConnectionProvider(Connection connection)
-
-
Method Detail
-
acquire
@NotNull public final @NotNull Connection acquire()
Description copied from interface:ConnectionProvider
Acquire 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:
acquire
in interfaceConnectionProvider
- Returns:
- A connection for the current
ExecuteContext
. Ifnull
is returned (e.g. by NoConnectionProvider), then statements cannot be executed. Attempts to execute statements will result in aDetachedException
.
-
release
public final void release(Connection released)
Description copied from interface:ConnectionProvider
Release a connection to the connection lifecycle handler.jOOQ will guarantee that every acquired connection is released exactly once.
- Specified by:
release
in interfaceConnectionProvider
- Parameters:
released
- A connection that was previously obtained fromConnectionProvider.acquire()
. This is nevernull
.
-
finalize
protected void finalize() throws Throwable
-
setConnection
public final void setConnection(Connection connection)
-
commit
public final void commit() throws DataAccessException
Convenience method to accessConnection.commit()
.- Throws:
DataAccessException
-
rollback
public final void rollback() throws DataAccessException
Convenience method to accessConnection.rollback()
.- Throws:
DataAccessException
-
rollback
public final void rollback(Savepoint savepoint) throws DataAccessException
Convenience method to accessConnection.rollback(Savepoint)
.- Throws:
DataAccessException
-
setSavepoint
@NotNull public final @NotNull Savepoint setSavepoint() throws DataAccessException
Convenience method to accessConnection.setSavepoint()
.- Throws:
DataAccessException
-
setSavepoint
@NotNull public final @NotNull Savepoint setSavepoint(String name) throws DataAccessException
Convenience method to accessConnection.setSavepoint(String)
.- Throws:
DataAccessException
-
releaseSavepoint
public final void releaseSavepoint(Savepoint savepoint) throws DataAccessException
Convenience method to accessConnection.releaseSavepoint(Savepoint)
.- Throws:
DataAccessException
-
setReadOnly
public final void setReadOnly(boolean readOnly) throws DataAccessException
Convenience method to accessConnection.setReadOnly(boolean)
.- Throws:
DataAccessException
-
isReadOnly
public final boolean isReadOnly() throws DataAccessException
Convenience method to accessConnection.isReadOnly()
.- Throws:
DataAccessException
-
setAutoCommit
public final void setAutoCommit(boolean autoCommit) throws DataAccessException
Convenience method to accessConnection.setAutoCommit(boolean)
.- Throws:
DataAccessException
-
getAutoCommit
public final boolean getAutoCommit() throws DataAccessException
Convenience method to accessConnection.getAutoCommit()
.- Throws:
DataAccessException
-
setHoldability
public final void setHoldability(int holdability) throws DataAccessException
Convenience method to accessConnection.setHoldability(int)
.- Throws:
DataAccessException
-
getHoldability
public final int getHoldability() throws DataAccessException
Convenience method to accessConnection.getHoldability()
.- Throws:
DataAccessException
-
setTransactionIsolation
public final void setTransactionIsolation(int level) throws DataAccessException
Convenience method to accessConnection.setTransactionIsolation(int)
.- Throws:
DataAccessException
-
getTransactionIsolation
public final int getTransactionIsolation() throws DataAccessException
Convenience method to accessConnection.getTransactionIsolation()
.- Throws:
DataAccessException
-
-