# Interface CloudSpannerJdbcPreparedStatement (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 CloudSpannerJdbcPreparedStatement extends PreparedStatement

This interface is implemented by [PreparedStatement](https://docs.oracle.com/javase/8/docs/api/java/sql/PreparedStatement.html)s that are created on Cloud Spanner
JDBC connections.

## Implements

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

## Methods

### partitionQuery(PartitionOptions partitionOptions, Options.QueryOption\[\] options)

    public abstract ResultSet partitionQuery(PartitionOptions partitionOptions, Options.QueryOption[] options)

Partitions this query, so it can be executed in parallel. This method returns a [ResultSet](https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSet.html) with a string-representation of the partitions that were created. These strings can
be used to execute a partition either on this connection or an any other connection (on this
host or an any other host) by calling the method [#runPartition()](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_runPartition__). This method will
automatically enable data boost for the query if [CloudSpannerJdbcConnection#isDataBoostEnabled()](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_isDataBoostEnabled__) returns true.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `partitionOptions` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.PartitionOptions` |
| `options` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.Options.QueryOption[]` |

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

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

### runPartition()

    public abstract ResultSet runPartition()

Executes the given partition of a query. The partition that should be executed must be set as a
string parameter on this [PreparedStatement](https://docs.oracle.com/javase/8/docs/api/java/sql/PreparedStatement.html) using #setString(int, String). The
value should be a string that was returned by #partitionQuery(PartitionOptions, QueryOption...).

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

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

### runPartitionedQuery(PartitionOptions partitionOptions, Options.QueryOption\[\] options)

    public abstract CloudSpannerJdbcPartitionedQueryResultSet runPartitionedQuery(PartitionOptions partitionOptions, Options.QueryOption[] options)

Executes the given query as a partitioned query. The query will first be partitioned using the
[#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_) method. Each of the partitions will
then be executed in the background, and the results will be merged into a single result set.

This method will use [CloudSpannerJdbcConnection#getMaxPartitionedParallelism()](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_getMaxPartitionedParallelism__)
threads to execute the partitioned query. Set this variable to a higher/lower value to
increase/decrease the degree of parallelism used for execution.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `partitionOptions` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.PartitionOptions` |
| `options` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-spanner-jdbc/latest/com.google.cloud.spanner.Options.QueryOption[]` |

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

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