Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

(Statement/PreparedStatement).executeUpdate() for statements that do not return anything (DDL, ClientSideStatements) throwing exception #1150

@rajatbhatta

Description

@rajatbhatta

PreparedStatement.executeUpdate() currently does not work for DDL statements, and throws an exception. It should execute it successfully and return 0 as the result. (Ref)

String DDL = "CREATE TABLE FOO (ID INT64 NOT NULL, NAME STRING(100)) PRIMARY KEY (ID)";
try (PreparedStatement pstmt = connection.prepareStatement(DDL)) {
    int updateCount = pstmt.executeUpdate();
    assertEquals(updateCount, 0);
}

The above fails with the exception com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory$JdbcSqlExceptionImpl: INVALID_ARGUMENT: Statement is not an update statement: CREATE TABLE FOO (ID INT64 NOT NULL, NAME STRING(100)) PRIMARY KEY (ID).

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/java-spanner-jdbc API.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions