fakesnow icon indicating copy to clipboard operation
fakesnow copied to clipboard

Statement 'USE SCHEMA SCHEMA2' cannot be executed using current API

Open tekumara opened this issue 9 months ago • 2 comments

When changing the schema in Dbeaver via Choose Database/Schema (CTRL+0) the JDBC driver errors with:

SQL Error [200042] [0A000]: Statement 'USE SCHEMA SCHEMA2' cannot be executed using current API.
Statement 'USE SCHEMA SCHEMA2' cannot be executed using current API.
Statement 'USE SCHEMA SCHEMA2' cannot be executed using current API.

From ~/Library/DBeaverData/workspace6/.metadata/dbeaver-debug.log:

2025-03-24 16:04:18.763 - Error during job 'Change active database' execution
net.snowflake.client.jdbc.SnowflakeSQLLoggedException: Statement 'USE SCHEMA SCHEMA2' cannot be executed using current API.
        at net.snowflake.client.jdbc.SnowflakeStatementV1.executeUpdateInternal(SnowflakeStatementV1.java:256)
        at net.snowflake.client.jdbc.SnowflakeStatementV1.executeLargeUpdate(SnowflakeStatementV1.java:206)
        at net.snowflake.client.jdbc.SnowflakeStatementV1.executeUpdate(SnowflakeStatementV1.java:192)
        at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeUpdate(JDBCStatementImpl.java:375)
        at org.jkiss.dbeaver.ext.snowflake.model.SnowflakeExecutionContext.setActiveSchema(SnowflakeExecutionContext.java:201)
        at org.jkiss.dbeaver.ext.snowflake.model.SnowflakeExecutionContext.setDefaultSchema(SnowflakeExecutionContext.java:131)
        at org.jkiss.dbeaver.ext.snowflake.model.SnowflakeExecutionContext.setDefaultSchema(SnowflakeExecutionContext.java:123)
        at org.jkiss.dbeaver.ext.generic.model.GenericExecutionContext.setDefaultSchema(GenericExecutionContext.java:1)
        at org.jkiss.dbeaver.model.exec.DBExecUtils.changeDefaultObject(DBExecUtils.java:452)
        at org.jkiss.dbeaver.model.exec.DBExecUtils.setExecutionContextDefaults(DBExecUtils.java:411)
        at org.jkiss.dbeaver.ui.actions.datasource.SelectActiveSchemaHandler$2.run(SelectActiveSchemaHandler.java:214)
        at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:119)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

snowflake-jdbc-3.22.0.jar see https://github.com/snowflakedb/snowflake-jdbc/blob/ebb315c4a01b18e571cff086d67aff33def10400/src/main/java/net/snowflake/client/jdbc/SnowflakeStatementV1.java#L256

tekumara avatar Mar 24 '25 05:03 tekumara

Happening because the server doesn't return statementTypeId which is used by the JDBC driver. See the types defined here.

tekumara avatar Jun 01 '25 02:06 tekumara

The python connector and JDBC driver both uses statementTypeId to determine if the statement is a DML statement.

tekumara avatar Jun 01 '25 02:06 tekumara