Top Description Fields Constructors Methods
org.jooq.tools.r2dbc

public Class DefaultConnection

extends Object
implements Connection
Class Inheritance
All Implemented Interfaces
io.r2dbc.spi.Connection, io.r2dbc.spi.Closeable
Known Direct Subclasses
org.jooq.tools.r2dbc.LoggingConnection
Imports
java.time.Duration, org.reactivestreams.Publisher, io.r2dbc.spi.Batch, .Connection, .ConnectionMetadata, .IsolationLevel, .Statement, .TransactionDefinition, .ValidationDepth

A default R2DBC Connection implementation delegating all R2DBC calls to an internal getDelegate().
Author
Lukas Eder

Field Summary

Modifier and TypeField and Description
private final Connection

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Publisher<Void>
beginTransaction()

Implements io.r2dbc.spi.Connection.beginTransaction.

Begins a new transaction.
public Publisher<Void>
beginTransaction(TransactionDefinition
attributes for the transaction.
definition
)

Implements io.r2dbc.spi.Connection.beginTransaction.

Begins a new transaction.
public Publisher<Void>
close()

Implements io.r2dbc.spi.Connection.close.

Release any resources held by the Connection.
public Publisher<Void>
commitTransaction()

Implements io.r2dbc.spi.Connection.commitTransaction.

Commits the current transaction.
public Batch
createBatch()

Implements io.r2dbc.spi.Connection.createBatch.

Creates a new Batch instance for building a batched request.
public Publisher<Void>
createSavepoint(String
the name of the savepoint to create
name
)

Implements io.r2dbc.spi.Connection.createSavepoint.

Creates a savepoint in the current transaction.
public Statement
createStatement(String
the SQL of the statement
sql
)

Implements io.r2dbc.spi.Connection.createStatement.

Creates a new statement for building a statement-based request.
public Connection
public ConnectionMetadata
getMetadata()

Implements io.r2dbc.spi.Connection.getMetadata.

Returns the ConnectionMetadata about the product this Connection is connected to.
public IsolationLevel
public boolean
isAutoCommit()

Implements io.r2dbc.spi.Connection.isAutoCommit.

Returns the auto-commit mode for this connection.
public Publisher<Void>
releaseSavepoint(String
the name of the savepoint to release
name
)

Implements io.r2dbc.spi.Connection.releaseSavepoint.

Releases a savepoint in the current transaction.
public Publisher<Void>
rollbackTransaction()

Implements io.r2dbc.spi.Connection.rollbackTransaction.

Rolls back the current transaction.
public Publisher<Void>
rollbackTransactionToSavepoint(String
the name of the savepoint to rollback to
name
)

Implements io.r2dbc.spi.Connection.rollbackTransactionToSavepoint.

Rolls back to a savepoint in the current transaction.
public Publisher<Void>
setAutoCommit(boolean
the isolation level for this transaction
autoCommit
)

Implements io.r2dbc.spi.Connection.setAutoCommit.

Configures the auto-commit mode for the current transaction.
public Publisher<Void>
setLockWaitTimeout(Duration
the lock timeout for this connection. Support for no timeout is vendor-specific.
timeout
)

Implements io.r2dbc.spi.Connection.setLockWaitTimeout.

Configures the lock acquisition timeout for statements to be executed using the current connection.
public Publisher<Void>
setStatementTimeout(Duration
the statement timeout for this connection. Duration#ZERO indicates no timeout.
timeout
)

Implements io.r2dbc.spi.Connection.setStatementTimeout.

Configures the statement timeout for statements to be executed using the current connection.
public Publisher<Void>
setTransactionIsolationLevel(IsolationLevel
the isolation level for this transaction
isolationLevel
)

Implements io.r2dbc.spi.Connection.setTransactionIsolationLevel.

Configures the isolation level for the connection.
public Publisher<Boolean>
validate(ValidationDepth
the validation depth
depth
)

Implements io.r2dbc.spi.Connection.validate.

Validates the connection according to the given ValidationDepth.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private final Connection delegate

Constructor Detail

DefaultConnectionback to summary
public DefaultConnection(Connection delegate)

Method Detail

beginTransactionback to summary
public Publisher<Void> beginTransaction()

Implements io.r2dbc.spi.Connection.beginTransaction.

Doc from io.r2dbc.spi.Connection.beginTransaction.

Begins a new transaction. Calling this method disables auto-commit mode.

Returns:Publisher<Void>

a Publisher that indicates that the transaction is open

Annotations
@Override
beginTransactionback to summary
public Publisher<Void> beginTransaction(TransactionDefinition definition)

Implements io.r2dbc.spi.Connection.beginTransaction.

Doc from io.r2dbc.spi.Connection.beginTransaction.

Begins a new transaction. Calling this method disables auto-commit mode. Beginning the transaction may fail if the TransactionDefinition conflicts with the connection configuration.

Parameters
definition:TransactionDefinition

attributes for the transaction.

Returns:Publisher<Void>

a Publisher that indicates that the transaction is open

Annotations
@Override
closeback to summary
public Publisher<Void> close()

Implements io.r2dbc.spi.Connection.close.

Doc from io.r2dbc.spi.Connection.close.

Release any resources held by the Connection.

Returns:Publisher<Void>

a Publisher that termination is complete

Annotations
@Override
commitTransactionback to summary
public Publisher<Void> commitTransaction()

Implements io.r2dbc.spi.Connection.commitTransaction.

Doc from io.r2dbc.spi.Connection.commitTransaction.

Commits the current transaction.

Returns:Publisher<Void>

a Publisher that indicates that a transaction has been committed

Annotations
@Override
createBatchback to summary
public Batch createBatch()

Implements io.r2dbc.spi.Connection.createBatch.

Doc from io.r2dbc.spi.Connection.createBatch.

Creates a new Batch instance for building a batched request.

Returns:Batch

a new Batch instance

Annotations
@Override
createSavepointback to summary
public Publisher<Void> createSavepoint(String name)

Implements io.r2dbc.spi.Connection.createSavepoint.

Doc from io.r2dbc.spi.Connection.createSavepoint.

Creates a savepoint in the current transaction.

Parameters
name:String

the name of the savepoint to create

Returns:Publisher<Void>

a Publisher that indicates that a savepoint has been created

Annotations
@Override
createStatementback to summary
public Statement createStatement(String sql)

Implements io.r2dbc.spi.Connection.createStatement.

Doc from io.r2dbc.spi.Connection.createStatement.

Creates a new statement for building a statement-based request.

Parameters
sql:String

the SQL of the statement

Returns:Statement

a new Statement instance

Annotations
@Override
getDelegateback to summary
public Connection getDelegate()
getMetadataback to summary
public ConnectionMetadata getMetadata()

Implements io.r2dbc.spi.Connection.getMetadata.

Doc from io.r2dbc.spi.Connection.getMetadata.

Returns the ConnectionMetadata about the product this Connection is connected to.

Returns:ConnectionMetadata

the ConnectionMetadata about the product this Connection is connected to

Annotations
@Override
getTransactionIsolationLevelback to summary
public IsolationLevel getTransactionIsolationLevel()

Implements io.r2dbc.spi.Connection.getTransactionIsolationLevel.

Doc from io.r2dbc.spi.Connection.getTransactionIsolationLevel.

Returns the IsolationLevel for this connection.

Isolation level is typically one of the following constants:

IsolationLevel is extensible so drivers can return a vendor-specific IsolationLevel.

Returns:IsolationLevel

the IsolationLevel for this connection.

Annotations
@Override
isAutoCommitback to summary
public boolean isAutoCommit()

Implements io.r2dbc.spi.Connection.isAutoCommit.

Doc from io.r2dbc.spi.Connection.isAutoCommit.

Returns the auto-commit mode for this connection.

Returns:boolean

true if the connection is in auto-commit mode; false otherwise.

Annotations
@Override
releaseSavepointback to summary
public Publisher<Void> releaseSavepoint(String name)

Implements io.r2dbc.spi.Connection.releaseSavepoint.

Doc from io.r2dbc.spi.Connection.releaseSavepoint.

Releases a savepoint in the current transaction. Calling this for drivers not supporting savepoint release results in a no-op.

Parameters
name:String

the name of the savepoint to release

Returns:Publisher<Void>

a Publisher that indicates that a savepoint has been released

Annotations
@Override
rollbackTransactionback to summary
public Publisher<Void> rollbackTransaction()

Implements io.r2dbc.spi.Connection.rollbackTransaction.

Doc from io.r2dbc.spi.Connection.rollbackTransaction.

Rolls back the current transaction.

Returns:Publisher<Void>

a Publisher that indicates that a transaction has been rolled back

Annotations
@Override
rollbackTransactionToSavepointback to summary
public Publisher<Void> rollbackTransactionToSavepoint(String name)

Implements io.r2dbc.spi.Connection.rollbackTransactionToSavepoint.

Doc from io.r2dbc.spi.Connection.rollbackTransactionToSavepoint.

Rolls back to a savepoint in the current transaction.

Parameters
name:String

the name of the savepoint to rollback to

Returns:Publisher<Void>

a Publisher that indicates that a savepoint has been rolled back to

Annotations
@Override
setAutoCommitback to summary
public Publisher<Void> setAutoCommit(boolean autoCommit)

Implements io.r2dbc.spi.Connection.setAutoCommit.

Doc from io.r2dbc.spi.Connection.setAutoCommit.

Configures the auto-commit mode for the current transaction. If a connection is in auto-commit mode, then all Statements will be executed and committed as individual transactions. Otherwise, in explicit transaction mode, transactions have to be started explicitly. A transaction needs to be either committed or rolled back to clean up the transaction state.

Calling this method during an active transaction and the auto-commit mode is changed, the transaction is committed. Calling this method without changing auto-commit mode this invocation results in a no-op.

Parameters
autoCommit:boolean

the isolation level for this transaction

Returns:Publisher<Void>

a Publisher that indicates that auto-commit mode has been configured

Annotations
@Override
setLockWaitTimeoutback to summary
public Publisher<Void> setLockWaitTimeout(Duration timeout)

Implements io.r2dbc.spi.Connection.setLockWaitTimeout.

Doc from io.r2dbc.spi.Connection.setLockWaitTimeout.

Configures the lock acquisition timeout for statements to be executed using the current connection. The default lock acquisition timeout is vendor-specific and can be specified for new connections through ConnectionFactoryOptions. If the timeout is exceeded, a R2dbcTimeoutException is raised.

In the case of Batch/Statement batching, it is vendor-specific as to whether the timeout is applied to individual SQL commands or the entire batch.

Parameters
timeout:Duration

the lock timeout for this connection. Support for no timeout is vendor-specific.

Returns:Publisher<Void>

a Publisher that indicates that a lock timeout has been configured

Annotations
@Override
setStatementTimeoutback to summary
public Publisher<Void> setStatementTimeout(Duration timeout)

Implements io.r2dbc.spi.Connection.setStatementTimeout.

Doc from io.r2dbc.spi.Connection.setStatementTimeout.

Configures the statement timeout for statements to be executed using the current connection. By default, there is no limit on the amount of time allowed for a running statement to complete unless specified through ConnectionFactoryOptions. If the limit is exceeded, a R2dbcTimeoutException is raised.

The minimum amount of time can be used to either let the data source cancel the statement or attempt a client-side cancellation. The timeout applies to statements through a combination of Statement#execute() and Result consumption. In the case of Batch/Statement batching, it is vendor-specific whether the timeout is applied to individual SQL commands or the entire batch.

Note that the timeout applies until receiving the first response from the data source and does not span until publisher completion.

Parameters
timeout:Duration

the statement timeout for this connection. Duration#ZERO indicates no timeout.

Returns:Publisher<Void>

a Publisher that indicates that a statement timeout has been configured

Annotations
@Override
setTransactionIsolationLevelback to summary
public Publisher<Void> setTransactionIsolationLevel(IsolationLevel isolationLevel)

Implements io.r2dbc.spi.Connection.setTransactionIsolationLevel.

Doc from io.r2dbc.spi.Connection.setTransactionIsolationLevel.

Configures the isolation level for the connection. When called outside a transaction, then the isolation level applies for all subsequent transactions. Setting the isolation level within a transaction results in vendor-specific behavior.

Isolation level is typically one of the following constants:

IsolationLevel is extensible so drivers can accept a vendor-specific IsolationLevel.

Parameters
isolationLevel:IsolationLevel

the isolation level for this transaction

Returns:Publisher<Void>

a Publisher that indicates that a transaction level has been configured

Annotations
@Override
validateback to summary
public Publisher<Boolean> validate(ValidationDepth depth)

Implements io.r2dbc.spi.Connection.validate.

Doc from io.r2dbc.spi.Connection.validate.

Validates the connection according to the given ValidationDepth. Emits true if the validation was successful or false if the validation failed. Does not emit errors and does not complete empty.

Parameters
depth:ValidationDepth

the validation depth

Returns:Publisher<Boolean>

a Publisher that indicates whether the validation was successful

Annotations
@Override