public class DataSourceConnectionProvider extends java.lang.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(javax.sql.DataSource dataSource) |
Modifier and Type | Method and Description |
---|---|
java.sql.Connection |
acquire()
Acquire a connection from the connection lifecycle handler.
|
javax.sql.DataSource |
dataSource() |
void |
release(java.sql.Connection connection)
Release a connection to the connection lifecycle handler.
|
public DataSourceConnectionProvider(javax.sql.DataSource dataSource)
public javax.sql.DataSource dataSource()
public java.sql.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(java.sql.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 © 2014. All Rights Reserved.