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
The general contract is that a
ConnectionProvider is
expected to always return the same connection, until this connection is
returned by jOOQ through ConnectionProvider.release(Connection) . |
void |
release(Connection released)
Release a connection to the connection lifecycle handler
The general contract is that a
ConnectionProvider must not
generate a new connection in ConnectionProvider.acquire() , before a previous
connection is returned. |
public DataSourceConnectionProvider(DataSource datasource)
public Connection acquire()
ConnectionProvider
The general contract is that a ConnectionProvider
is
expected to always return the same connection, until this connection is
returned by jOOQ through ConnectionProvider.release(Connection)
.
acquire
in interface ConnectionProvider
public void release(Connection released)
ConnectionProvider
The general contract is that a ConnectionProvider
must not
generate a new connection in ConnectionProvider.acquire()
, before a previous
connection is returned.
release
in interface ConnectionProvider
Copyright © 2013. All Rights Reserved.