Connection object can consist of any number of transport
connections to the underlying database or represent a session over a multiplexed transport connection. For maximum portability, connections should be used synchronously.
Connection objects initiate database conversations for transaction management and statement execution. Objects created by a connection are only valid as long as the connection remains
open.
When configuring a connection, R2DBC applications should use the appropriate methods such as beginTransaction(), setAutoCommit(boolean) and
setTransactionIsolationLevel(IsolationLevel) to change transaction properties instead. Applications should not execute SQL commands directly to change the connection configuration when
a R2DBC method is available.
New connections are by default created in auto-commit mode.
Statement, Result, Row
| Modifier and Type | Method and Description |
|---|---|
| public Publisher | Returns: aPublisher that indicates that the transaction is openBegins a new transaction. |
| public Publisher | Returns: aPublisher that indicates that the transaction is openattributes for the transaction. definition)Begins a new transaction. |
| public Publisher | Returns: aPublisher that termination is completeRedeclares io. Connection.
|
| public Publisher | Returns: aPublisher that indicates that a transaction has been committedCommits the current transaction. |
| public Batch | Returns: a newBatch instanceCreates a new |
| public Publisher | Returns: aPublisher that indicates that a savepoint has been createdthe name of the savepoint to create name)Creates a savepoint in the current transaction. |
| public Statement | Returns: a newStatement instancethe SQL of the statement sql)Creates a new statement for building a statement-based request. |
| public ConnectionMetadata | |
| public IsolationLevel | Returns: theIsolationLevel for this connection.Returns the |
| public boolean | Returns: true if the connection is in auto-commit mode; false otherwise.Returns the auto-commit mode for this connection. |
| public Publisher | Returns: aPublisher that indicates that a savepoint has been releasedthe name of the savepoint to release name)Releases a savepoint in the current transaction. |
| public Publisher | Returns: aPublisher that indicates that a transaction has been rolled backRolls back the current transaction. |
| public Publisher | Returns: aPublisher that indicates that a savepoint has been rolled back tothe name of the savepoint to rollback to name)Rolls back to a savepoint in the current transaction. |
| public Publisher | Returns: aPublisher that indicates that auto-commit mode has been configuredthe isolation level for this transaction autoCommit)Configures the auto-commit mode for the current transaction. |
| public Publisher | Returns: aPublisher that indicates that a lock timeout has been configuredthe lock timeout for this connection. Support for timeout)no timeout is vendor-specific.Configures the lock acquisition timeout for statements to be executed using the current connection. |
| public Publisher | Returns: aPublisher that indicates that a statement timeout has been configuredthe statement timeout for this connection. timeout)Duration#ZERO indicates no timeout.Configures the statement timeout for statements to be executed using the current connection. |
| public Publisher | Returns: aPublisher that indicates that a transaction level has been configuredthe isolation level for this transaction isolationLevel)Configures the isolation level for the connection. |
| public Publisher | Returns: aPublisher that indicates whether the validation was successfulthe validation depth depth)Validates the connection according to the given |
| beginTransaction | back to summary |
|---|---|
| public Publisher Begins a new transaction. Calling this method disables | |
| beginTransaction | back to summary |
|---|---|
| public Publisher Begins a new transaction. Calling this method disables
| |
| close | back to summary |
|---|---|
| public Publisher Redeclares io. Release any resources held by the | |
| commitTransaction | back to summary |
|---|---|
| public Publisher Commits the current transaction. | |
| createBatch | back to summary |
|---|---|
| public Batch createBatch() Creates a new | |
| createSavepoint | back to summary |
|---|---|
| public Publisher Creates a savepoint in the current transaction.
| |
| createStatement | back to summary |
|---|---|
| public Statement createStatement(String sql) Creates a new statement for building a statement-based request.
| |
| getMetadata | back to summary |
|---|---|
| public ConnectionMetadata getMetadata() Returns the
| |
| getTransactionIsolationLevel | back to summary |
|---|---|
| public IsolationLevel getTransactionIsolationLevel() Returns the Isolation level is typically one of the following constants:
| |
| isAutoCommit | back to summary |
|---|---|
| public boolean isAutoCommit() Returns the auto-commit mode for this connection.
| |
| releaseSavepoint | back to summary |
|---|---|
| public Publisher Releases a savepoint in the current transaction. Calling this for drivers not supporting savepoint release results in a no-op.
| |
| rollbackTransaction | back to summary |
|---|---|
| public Publisher Rolls back the current transaction. | |
| rollbackTransactionToSavepoint | back to summary |
|---|---|
| public Publisher Rolls back to a savepoint in the current transaction.
| |
| setAutoCommit | back to summary |
|---|---|
| public Publisher Configures the auto-commit mode for the current transaction.
If a connection is in auto-commit mode, then all 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. | |
| setLockWaitTimeout | back to summary |
|---|---|
| public Publisher 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
In the case of
| |
| setStatementTimeout | back to summary |
|---|---|
| public Publisher 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
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 Note that the timeout applies until receiving the first response from the data source and does not span until
| |
| setTransactionIsolationLevel | back to summary |
|---|---|
| public Publisher 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:
| |
| validate | back to summary |
|---|---|
| public Publisher Validates the connection according to the given
| |