public class DataSourceConnectionProvider extends Object implements ConnectionProvider
DataSource
-oriented
ConnectionProvider
This implementation wraps a JDBC DataSource
. jOOQ will use that data
source for initialising connections, and creating statements.
Use this connection provider if you want to run distributed transactions,
such as javax.transaction.UserTransaction
. jOOQ will
close()
all connections after query execution (and
result fetching) in order to return the connection to the connection pool. If
you do not use distributed transactions, this will produce driver-specific
behaviour at the end of query execution at close()
invocation
(e.g. a transaction rollback). Use a DefaultConnectionProvider
instead, to control the connection's lifecycle, or implement your own
ConnectionProvider
.
Constructor and Description |
---|
DataSourceConnectionProvider(DataSource dataSource) |
Modifier and Type | Method and Description |
---|---|
Connection |
acquire()
Acquire a connection from the connection lifecycle handler.
|
DataSource |
dataSource() |
void |
release(Connection connection)
Release a connection to the connection lifecycle handler.
|
public DataSourceConnectionProvider(DataSource dataSource)
public DataSource dataSource()
public Connection acquire()
ConnectionProvider
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
ConnectionProvider.release(Connection)
exactly once.
acquire
in interface ConnectionProvider
ExecuteContext
.public void release(Connection connection)
ConnectionProvider
jOOQ will guarantee that every acquired connection is released exactly once.
release
in interface ConnectionProvider
connection
- A connection that was previously obtained from
ConnectionProvider.acquire()
. This is never null
.Copyright © 2015. All Rights Reserved.