# Interface CloudSpannerJdbcConnection (2.40.0)

2.40.0 (latest) 2.38.0 2.35.4 2.34.0 2.33.2 2.32.3 2.31.2 2.30.4 2.28.0 2.27.1 2.26.1 2.25.1 2.24.1 2.23.0 2.22.1 2.21.0 2.20.2 2.19.3 2.18.1 2.17.0 2.16.1 2.15.5 2.14.6 2.13.4 2.11.4 2.10.0 2.9.16 2.8.0 2.7.12 2.6.4 2.5.11

    public interface CloudSpannerJdbcConnection extends Connection

JDBC connection with a number of additional Cloud Spanner specific methods. JDBC connections that
are returned by the Cloud Spanner [JdbcDriver](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.JdbcDriver) will implement this interface.

Calling Connection#unwrap(Class) with `CloudSpannerJdbcConnection` class as
input on a [Connection](https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html) returned by the Cloud Spanner JDBC Driver will return a [CloudSpannerJdbcConnection](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection) instance.

## Implements

[Connection](https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html)

## Methods

### addTransactionRetryListener(TransactionRetryListener listener)

    public abstract void addTransactionRetryListener(TransactionRetryListener listener)

See Also: [com.google.cloud.spanner.connection.Connection#addTransactionRetryListener(com.google.cloud.spanner.connection.TransactionRetryListener)](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.Connection#com_google_cloud_spanner_connection_Connection_addTransactionRetryListener_com_google_cloud_spanner_connection_TransactionRetryListener_)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `listener` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.TransactionRetryListener` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` | if the Connection is closed. |

### addTransactionRetryListener(TransactionRetryListener listener) (deprecated)

    public abstract void addTransactionRetryListener(TransactionRetryListener listener)

Use [#addTransactionRetryListener(com.google.cloud.spanner.connection.TransactionRetryListener)](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection#com_google_cloud_spanner_jdbc_CloudSpannerJdbcConnection_addTransactionRetryListener_com_google_cloud_spanner_connection_TransactionRetryListener_)
instead.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `listener` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.TransactionRetryListener` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### bufferedWrite(Mutation mutation)

    public abstract void bufferedWrite(Mutation mutation)

Buffers the given mutation locally on the current transaction of this [Connection](https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html). The
mutation will be written to the database at the next call to [Connection#commit()](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.Connection#com_google_cloud_spanner_connection_Connection_commit__). The
value will not be readable on this [Connection](https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html) before the transaction is committed.

Calling this method is only allowed when not in autocommit mode. See [CloudSpannerJdbcConnection#write(Mutation)](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection#com_google_cloud_spanner_jdbc_CloudSpannerJdbcConnection_write_com_google_cloud_spanner_Mutation_) for writing mutations in autocommit mode.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `mutation` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.Mutation` the [Mutation](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.Mutation) to buffer for writing to the database on the next commit. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` | if the Connection is in autocommit mode or the Connection is closed. |

### bufferedWrite(Iterable\<Mutation\> mutations)

    public abstract void bufferedWrite(Iterable<Mutation> mutations)

Buffers the given mutations locally on the current transaction of this [Connection](https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html). The
mutations will be written to the database at the next call to [Connection#commit()](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.Connection#com_google_cloud_spanner_connection_Connection_commit__). The
values will not be readable on this [Connection](https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html) before the transaction is committed.

Calling this method is only allowed when not in autocommit mode. See [CloudSpannerJdbcConnection#write(Iterable)](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection#com_google_cloud_spanner_jdbc_CloudSpannerJdbcConnection_write_java_lang_Iterable_com_google_cloud_spanner_Mutation__) for writing mutations in autocommit mode.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `mutations` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.Mutation>` the [Mutation](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.Mutation)s to buffer for writing to the database on the next commit. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` | if the Connection is in autocommit mode or the Connection is closed. |

### getAutoBatchDmlUpdateCount()

    public default long getAutoBatchDmlUpdateCount()

Returns the update count that is returned for DML statements that are buffered during an
automatic DML batch.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### getAutocommitDmlMode()

    public abstract AutocommitDmlMode getAutocommitDmlMode()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.AutocommitDmlMode` | the current [AutocommitDmlMode](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.AutocommitDmlMode) setting for this connection. This method may only be called on a connection that is in autocommit mode and not while in a temporary transaction. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### getCommitResponse()

    public abstract CommitResponse getCommitResponse()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.CommitResponse` | the [CommitResponse](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.CommitResponse) of the last read/write transaction. If the last transaction was not a read/write transaction, or a read/write transaction that did not return a [CommitResponse](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.CommitResponse) because the transaction was not committed, the method will throw a [SQLException](https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html). The [CommitResponse](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.CommitResponse) will include [CommitStats](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.CommitStats) if [#isReturnCommitStats()](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection#com_google_cloud_spanner_jdbc_CloudSpannerJdbcConnection_isReturnCommitStats__) returns true. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### getCommitTimestamp()

    public abstract Timestamp getCommitTimestamp()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/Timestamp.html` | the commit [Timestamp](https://docs.oracle.com/javase/8/docs/api/java/sql/Timestamp.html) of the last read/write transaction. If the last transaction was not a read/write transaction, or a read/write transaction that did not return a commit timestamp because the transaction was not committed, the method will throw a [SQLException](https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html). |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### getConnectionUrl()

    public abstract String getConnectionUrl()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | a connection URL that can be used to create a new [Connection](https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html) that is equal to the initial state of this connection. If this connection was initially opened in read-only mode, and later changed to read-write, this will not be reflected in the connection URL that is returned. |

### getDatabaseClient()

    public default DatabaseClient getDatabaseClient()

Returns the underlying [DatabaseClient](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.DatabaseClient) that is used by this connection. Operations that
are executed on the [DatabaseClient](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.DatabaseClient) that is returned has no impact on this [Connection](https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html), e.g. starting a read/write transaction on the [DatabaseClient](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.DatabaseClient) will not
start a transaction on this connection.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.DatabaseClient` |   |

### getDatabaseId()

    public default DatabaseId getDatabaseId()

Returns the [DatabaseId](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.DatabaseId) of the database that this [Connection](https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html) is connected to.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.DatabaseId` |   |

### getDialect()

    public default Dialect getDialect()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.Dialect` | The [Dialect](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.Dialect) that is used by this connection. |

### getMaxPartitionedParallelism()

    public default int getMaxPartitionedParallelism()

Returns the maximum degree of parallelism that is used for partitioned queries.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### getMaxPartitions()

    public default int getMaxPartitions()

Gets the maximum number of partitions that should be included as a hint to Cloud Spanner when
partitioning a query on this connection. Note that this is only a hint and Cloud Spanner might
choose to ignore the hint.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### getOptimizerVersion()

    public abstract String getOptimizerVersion()

Gets the current query optimizer version of this connection.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | The query optimizer version that is currently used by this connection. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### getProtoDescriptors()

    public default byte[] getProtoDescriptors()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `byte[]` | The proto descriptor that will be used with the next DDL statement (single or batch) that is executed on this connection. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### getReadOnlyStaleness()

    public abstract TimestampBound getReadOnlyStaleness()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.TimestampBound` | the read-only staleness setting for the current read-only transaction. This method may only be called when the current transaction is a read-only transaction, or when the connection is in read-only and autocommit mode. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### getReadTimestamp()

    public abstract Timestamp getReadTimestamp()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/Timestamp.html` | the read [Timestamp](https://docs.oracle.com/javase/8/docs/api/java/sql/Timestamp.html) of the last read-only transaction. If the last transaction was not a read-only transaction, or a read-only transaction that did not return a read timestamp because no data was read, the method will throw a [SQLException](https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html). |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### getSavepointSupport()

    public abstract SavepointSupport getSavepointSupport()

Returns the current savepoint support for this connection.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.SavepointSupport` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### getSpanner()

    public default Spanner getSpanner()

Returns the underlying [Spanner](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.Spanner) instance that is used by this connection.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.Spanner` |   |

### getStatementTag()

    public default String getStatementTag()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | The statement tag that will be used with the next statement that is executed on this connection. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### getTransactionMode()

    public abstract TransactionMode getTransactionMode()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.TransactionMode` | the transaction mode of the current transaction. This method may only be called when the connection is in a transaction. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### getTransactionRetryListeners() (deprecated)

    public abstract Iterator<TransactionRetryListener> getTransactionRetryListeners()

Use [#getTransactionRetryListenersFromConnection()](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection#com_google_cloud_spanner_jdbc_CloudSpannerJdbcConnection_getTransactionRetryListenersFromConnection__) instead.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.TransactionRetryListener>` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### getTransactionRetryListenersFromConnection()

    public abstract Iterator<TransactionRetryListener> getTransactionRetryListenersFromConnection()

See Also: [com.google.cloud.spanner.connection.Connection#getTransactionRetryListeners()](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.Connection#com_google_cloud_spanner_connection_Connection_getTransactionRetryListeners__)

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.TransactionRetryListener>` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` | if the Connection is closed. |

### getTransactionTag()

    public default String getTransactionTag()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | The transaction tag of the current transaction. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### isAutoBatchDml()

    public default boolean isAutoBatchDml()

Returns whether automatic DML batching is enabled on this connection.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### isAutoBatchDmlUpdateCountVerification()

    public default boolean isAutoBatchDmlUpdateCountVerification()

Indicates whether the update counts of automatic DML batches should be verified.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### isAutoPartitionMode()

    public default boolean isAutoPartitionMode()

Returns whether this connection will execute all queries as partitioned queries.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### isDataBoostEnabled()

    public default boolean isDataBoostEnabled()

Returns whether data boost is enabled for partitioned queries. See also [CloudSpannerJdbcStatement#partitionQuery(String, PartitionOptions, QueryOption...)](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcStatement#com_google_cloud_spanner_jdbc_CloudSpannerJdbcStatement_partitionQuery_) and [CloudSpannerJdbcPreparedStatement#partitionQuery(PartitionOptions, QueryOption...)](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcPreparedStatement#com_google_cloud_spanner_jdbc_CloudSpannerJdbcPreparedStatement_partitionQuery_).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### isInTransaction()

    public abstract boolean isInTransaction()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | `true` if this connection has a transaction (that has not necessarily started). This method will only return false when the [Connection](https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html) is in autocommit mode and no explicit transaction has been started by executing `BEGIN TRANSACTION`. If the [Connection](https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html) is not in autocommit mode, there will always be a transaction. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### isRetryAbortsInternally()

    public abstract boolean isRetryAbortsInternally()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | `true` if this connection will automatically retry read/write transactions that abort. This method may only be called when the connection is in read/write transactional mode and no transaction has been started yet. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### isReturnCommitStats()

    public abstract boolean isReturnCommitStats()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | true if this connection requests commit statistics from Cloud Spanner. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### isTransactionStarted()

    public abstract boolean isTransactionStarted()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | `true` if this connection has a transaction that has started. A transaction is automatically started by the first statement that is executed in the transaction. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### removeTransactionRetryListener(TransactionRetryListener listener)

    public abstract boolean removeTransactionRetryListener(TransactionRetryListener listener)

See Also: [com.google.cloud.spanner.connection.Connection#removeTransactionRetryListener(com.google.cloud.spanner.connection.TransactionRetryListener)](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.Connection#com_google_cloud_spanner_connection_Connection_removeTransactionRetryListener_com_google_cloud_spanner_connection_TransactionRetryListener_)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `listener` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.TransactionRetryListener` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` | if the Connection is closed. |

### removeTransactionRetryListener(TransactionRetryListener listener) (deprecated)

    public abstract boolean removeTransactionRetryListener(TransactionRetryListener listener)

Use [#removeTransactionRetryListener(com.google.cloud.spanner.connection.TransactionRetryListener)](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection#com_google_cloud_spanner_jdbc_CloudSpannerJdbcConnection_removeTransactionRetryListener_com_google_cloud_spanner_connection_TransactionRetryListener_)
instead.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `listener` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.TransactionRetryListener` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setAutoBatchDml(boolean autoBatchDml)

    public default void setAutoBatchDml(boolean autoBatchDml)

Enables or disables automatic batching of DML statements. When enabled, DML statements that are
executed on this connection will be buffered in memory instead of actually being executed. The
buffered DML statements are flushed to Spanner when a statement that cannot be part of a DML
batch is executed on the connection. This can be a query, a DDL statement with a THEN RETURN
clause, or a Commit call. The update count that is returned for DML statements that are
buffered is determined by the value that has been set with [#setAutoBatchDmlUpdateCount(long)](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection#com_google_cloud_spanner_jdbc_CloudSpannerJdbcConnection_setAutoBatchDmlUpdateCount_long_). The default is 1. The connection verifies that the update
counts that were returned while buffering DML statements match the actual update counts that
are returned by Spanner when the batch is executed. This verification can be disabled by
calling [#setAutoBatchDmlUpdateCountVerification(boolean)](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection#com_google_cloud_spanner_jdbc_CloudSpannerJdbcConnection_setAutoBatchDmlUpdateCountVerification_boolean_).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `autoBatchDml` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setAutoBatchDmlUpdateCount(long updateCount)

    public default void setAutoBatchDmlUpdateCount(long updateCount)

Sets the update count that is returned for DML statements that are buffered during an automatic
DML batch. This value is only used if [#isAutoBatchDml()](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection#com_google_cloud_spanner_jdbc_CloudSpannerJdbcConnection_isAutoBatchDml__) is enabled.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `updateCount` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setAutoBatchDmlUpdateCountVerification(boolean verification)

    public default void setAutoBatchDmlUpdateCountVerification(boolean verification)

Sets whether the update count that is returned by Spanner after executing an automatic DML
batch should be verified against the update counts that were returned during the buffering of
those statements.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `verification` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setAutoPartitionMode(boolean alwaysUsePartitionedQueries)

    public default void setAutoPartitionMode(boolean alwaysUsePartitionedQueries)

Sets whether this connection should always use partitioned queries when a query is executed on
this connection. Setting this flag to `true` and then executing a query that cannot
be partitioned, or executing a query in a read/write transaction, will cause an error. Use this
flag in combination with [#setDataBoostEnabled(boolean)](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection#com_google_cloud_spanner_jdbc_CloudSpannerJdbcConnection_setDataBoostEnabled_boolean_) to force all queries on this
connection to use data boost.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `alwaysUsePartitionedQueries` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setAutocommitDmlMode(AutocommitDmlMode mode)

    public abstract void setAutocommitDmlMode(AutocommitDmlMode mode)

Sets the mode for executing DML statements in autocommit mode for this connection. This setting
is only used when the connection is in autocommit mode, and may only be set while the
transaction is in autocommit mode and not in a temporary transaction. The autocommit
transaction mode is reset to its default value of [AutocommitDmlMode#TRANSACTIONAL](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.AutocommitDmlMode#com_google_cloud_spanner_connection_AutocommitDmlMode_TRANSACTIONAL) when
autocommit mode is changed on the connection.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `mode` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.AutocommitDmlMode` The DML autocommit mode to use - [AutocommitDmlMode#TRANSACTIONAL](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.AutocommitDmlMode#com_google_cloud_spanner_connection_AutocommitDmlMode_TRANSACTIONAL) DML statements are executed as single read-write transaction. After successful execution, the DML statement is guaranteed to have been applied exactly once to the database - [AutocommitDmlMode#PARTITIONED_NON_ATOMIC](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.AutocommitDmlMode#com_google_cloud_spanner_connection_AutocommitDmlMode_PARTITIONED_NON_ATOMIC) DML statements are executed as partitioned DML transactions. If an error occurs during the execution of the DML statement, it is possible that the statement has been applied to some but not all of the rows specified in the statement. <br /> |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setDataBoostEnabled(boolean dataBoostEnabled)

    public default void setDataBoostEnabled(boolean dataBoostEnabled)

Enable data boost for partitioned queries. See also [CloudSpannerJdbcStatement#partitionQuery(String, PartitionOptions, QueryOption...)](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcStatement#com_google_cloud_spanner_jdbc_CloudSpannerJdbcStatement_partitionQuery_) and [CloudSpannerJdbcPreparedStatement#partitionQuery(PartitionOptions, QueryOption...)](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcPreparedStatement#com_google_cloud_spanner_jdbc_CloudSpannerJdbcPreparedStatement_partitionQuery_).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `dataBoostEnabled` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setMaxPartitionedParallelism(int maxThreads)

    public default void setMaxPartitionedParallelism(int maxThreads)

Sets the maximum degree of parallelism that is used when executing a partitioned query. A
partitioned query will use up to `maxThreads` to execute and retrieve the results
from Cloud Spanner. Set this value to `0`\> to use the number of available processors
as returned by Runtime#availableProcessors().

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `maxThreads` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setMaxPartitions(int maxPartitions)

    public default void setMaxPartitions(int maxPartitions)

Sets the maximum number of partitions that should be included as a hint to Cloud Spanner when
partitioning a query on this connection. Note that this is only a hint and Cloud Spanner might
choose to ignore the hint.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `maxPartitions` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setOptimizerVersion(String optimizerVersion)

    public abstract void setOptimizerVersion(String optimizerVersion)

Sets the query optimizer version to use for this connection.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `optimizerVersion` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` The query optimizer version to use. Must be a valid optimizer version number, the string `LATEST` or an empty string. The empty string will instruct the connection to use the optimizer version that is defined in the environment variable `SPANNER_OPTIMIZER_VERSION`. If no value is specified in the environment variable, the default query optimizer of Cloud Spanner is used. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setProtoDescriptors(byte\[\] protoDescriptors)

    public default void setProtoDescriptors(byte[] protoDescriptors)

Sets the proto descriptors to use for the next DDL statement (single or batch) that will be
executed. The proto descriptor is automatically cleared after the statement is executed.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `protoDescriptors` | `byte[]` The proto descriptors to use with the next DDL statement (single or batch) that will be executed on this connection. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setProtoDescriptors(InputStream protoDescriptors)

    public default void setProtoDescriptors(InputStream protoDescriptors)

Sets the proto descriptors to use for the next DDL statement (single or batch) that will be
executed. The proto descriptor is automatically cleared after the statement is executed.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `protoDescriptors` | `https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html` The proto descriptors to use with the next DDL statement (single or batch) that will be executed on this connection. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### setReadOnlyStaleness(TimestampBound staleness)

    public abstract void setReadOnlyStaleness(TimestampBound staleness)

Sets the staleness to use for the current read-only transaction. This method may only be called
when the transaction mode of the current transaction is [TransactionMode#READ_ONLY_TRANSACTION](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.TransactionMode#com_google_cloud_spanner_connection_TransactionMode_READ_ONLY_TRANSACTION) and there is no transaction that has started, or when
the connection is in read-only and autocommit mode.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `staleness` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.TimestampBound` The staleness to use for the current but not yet started read-only transaction |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setRetryAbortsInternally(boolean retryAbortsInternally)

    public abstract void setRetryAbortsInternally(boolean retryAbortsInternally)

Sets whether this connection will internally retry read/write transactions that abort. The
default is `true`. When internal retry is enabled, the [Connection](https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html) will keep
track of a running SHA256 checksum of all [ResultSet](https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSet.html)s that have been returned from Cloud
Spanner. If the checksum that is calculated during an internal retry differs from the original
checksum, the transaction will abort with an [AbortedDueToConcurrentModificationException](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.AbortedDueToConcurrentModificationException).

Note that retries of a read/write transaction that calls a non-deterministic function on
Cloud Spanner, such as CURRENT_TIMESTAMP(), will never be successful, as the data returned
during the retry will always be different from the original transaction.

It is also highly recommended that all queries in a read/write transaction have an ORDER BY
clause that guarantees that the data is returned in the same order as in the original
transaction if the transaction is internally retried. The most efficient way to achieve this is
to always include the primary key columns at the end of the ORDER BY clause.

This method may only be called when the connection is in read/write transactional mode and
no transaction has been started yet.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `retryAbortsInternally` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` Set to `true` to internally retry transactions that are aborted by Spanner. When set to `false`, any database call on a transaction that has been aborted by Cloud Spanner will throw an [AbortedException](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.AbortedException) instead of being retried. Set this to false if your application already uses retry loops to handle [AbortedException](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.AbortedException)s. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setReturnCommitStats(boolean returnCommitStats)

    public abstract void setReturnCommitStats(boolean returnCommitStats)

Sets whether this connection should request commit statistics from Cloud Spanner for read/write
transactions and for DML statements in autocommit mode.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `returnCommitStats` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setSavepointSupport(SavepointSupport savepointSupport)

    public abstract void setSavepointSupport(SavepointSupport savepointSupport)

Sets how savepoints should be supported on this connection.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `savepointSupport` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.SavepointSupport` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setStatementTag(String tag)

    public default void setStatementTag(String tag)

Sets the statement tag to use for the next statement that will be executed. The tag is
automatically cleared after the statement is executed. Statement tags can be used both with
autocommit=true and autocommit=false, and can be used for partitioned DML.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `tag` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` The statement tag to use with the next statement that will be executed on this connection. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setTransactionMode(TransactionMode transactionMode)

    public abstract void setTransactionMode(TransactionMode transactionMode)

Sets the transaction mode to use for current transaction. This method may only be called when
in a transaction, and before the transaction is actually started, i.e. before any statements
have been executed in the transaction.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `transactionMode` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.TransactionMode` The transaction mode to use for the current transaction. - [TransactionMode#READ_ONLY_TRANSACTION](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.TransactionMode#com_google_cloud_spanner_connection_TransactionMode_READ_ONLY_TRANSACTION) will create a read-only transaction and prevent any changes to written to the database through this transaction. The read timestamp to be used will be determined based on the current readOnlyStaleness setting of this connection. It is recommended to use [TransactionMode#READ_ONLY_TRANSACTION](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.TransactionMode#com_google_cloud_spanner_connection_TransactionMode_READ_ONLY_TRANSACTION) instead of [TransactionMode#READ_WRITE_TRANSACTION](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.TransactionMode#com_google_cloud_spanner_connection_TransactionMode_READ_WRITE_TRANSACTION) when possible, as read-only transactions do not acquire locks on Cloud Spanner, and read-only transactions never abort. - [TransactionMode#READ_WRITE_TRANSACTION](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.connection.TransactionMode#com_google_cloud_spanner_connection_TransactionMode_READ_WRITE_TRANSACTION) this value is only allowed when the connection is not in read-only mode and will create a read-write transaction. If [CloudSpannerJdbcConnection#isRetryAbortsInternally()](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection#com_google_cloud_spanner_jdbc_CloudSpannerJdbcConnection_isRetryAbortsInternally__) is `true`, each read/write transaction will keep track of a running SHA256 checksum for each [ResultSet](https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSet.html) that is returned in order to be able to retry the transaction in case the transaction is aborted by Spanner. <br /> |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### setTransactionTag(String tag)

    public default void setTransactionTag(String tag)

Sets the transaction tag to use for the current transaction. This method may only be called
when in a transaction, and before the transaction is actually started, i.e. before any
statements have been executed in the transaction.

The tag will be set as the transaction tag of all statements during the transaction, and as
the transaction tag of the commit.

The transaction tag will automatically be cleared after the transaction has ended.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `tag` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` The tag to use. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` |   |

### write(Mutation mutation)

    public abstract void write(Mutation mutation)

Writes the specified mutation directly to the database and commits the change. The value is
readable after the successful completion of this method. Writing multiple mutations to a
database by calling this method multiple times mode is inefficient, as each call will need a
round trip to the database. Instead, you should consider writing the mutations together by
calling [CloudSpannerJdbcConnection#write(Iterable)](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection#com_google_cloud_spanner_jdbc_CloudSpannerJdbcConnection_write_java_lang_Iterable_com_google_cloud_spanner_Mutation__).

Calling this method is only allowed in autocommit mode. See [CloudSpannerJdbcConnection#bufferedWrite(Iterable)](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection#com_google_cloud_spanner_jdbc_CloudSpannerJdbcConnection_bufferedWrite_java_lang_Iterable_com_google_cloud_spanner_Mutation__) for writing mutations in transactions.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `mutation` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.Mutation` The [Mutation](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.Mutation) to write to the database. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` | if the Connection is not in autocommit mode or if the Connection is closed. |

### write(Iterable\<Mutation\> mutations)

    public abstract void write(Iterable<Mutation> mutations)

Writes the specified mutations directly to the database and commits the changes. The values are
readable after the successful completion of this method.

Calling this method is only allowed in autocommit mode. See [CloudSpannerJdbcConnection#bufferedWrite(Iterable)](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection#com_google_cloud_spanner_jdbc_CloudSpannerJdbcConnection_bufferedWrite_java_lang_Iterable_com_google_cloud_spanner_Mutation__) for writing mutations in transactions.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `mutations` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.Mutation>` The [Mutation](https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.Mutation)s to write to the database. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html` | if the Connection is not in autocommit mode or if the Connection is closed. |