Top Description Fields Constructors Methods
org.jooq.impl

public Class DataSourceConnectionProvider

extends Object
implements ConnectionProvider
Class Inheritance
All Implemented Interfaces
org.jooq.ConnectionProvider
Imports
java.sql.Connection, .SQLException, javax.sql.DataSource, org.jooq.ConnectionProvider, org.jooq.exception.DataAccessException, org.jetbrains.annotations.NotNull

A default implementation for a pooled 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.

Authors
Aaron Digulla, Lukas Eder

Field Summary

Modifier and TypeField and Description
private final DataSource

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public @NotNull Connection
acquire()

Implements org.jooq.ConnectionProvider.acquire.

Acquire a connection from the connection lifecycle handler.
public @NotNull DataSource
public void
release(Connection
A connection that was previously obtained from acquire(). This is never null.
connection
)

Implements org.jooq.ConnectionProvider.release.

Release a connection to the connection lifecycle handler.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dataSourceback to summary
private final DataSource dataSource

Constructor Detail

DataSourceConnectionProviderback to summary
public DataSourceConnectionProvider(DataSource dataSource)

Method Detail

acquireback to summary
public @NotNull Connection acquire()

Implements org.jooq.ConnectionProvider.acquire.

Doc from org.jooq.ConnectionProvider.acquire.

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 release(Connection) exactly once.

Returns:@NotNull Connection

A connection for the current ExecuteContext. If null is returned (e.g. by NoConnectionProvider), then statements cannot be executed. Attempts to execute statements will result in a DetachedException.

Annotations
@NotNull
@Override
dataSourceback to summary
public @NotNull DataSource dataSource()
Annotations
@NotNull
releaseback to summary
public void release(Connection connection)

Implements org.jooq.ConnectionProvider.release.

Doc from org.jooq.ConnectionProvider.release.

Release a connection to the connection lifecycle handler.

jOOQ will guarantee that every acquired connection is released exactly once.

Parameters
connection:Connection

A connection that was previously obtained from acquire(). This is never null.

Annotations
@Override