arunan
arunan

Reputation: 961

Encountered SQL error: net.snowflake.client.jdbc.SnowflakeSQLException: Statement is closed

I am executing a query programmatically using snowflake-jdbc driver (version:3.12.9). Executing the query in snowflake client is working. If I execute the same query programmatically I am getting the following exception,

select count(*) as total_record_count from TABLE_NAME

    
WARNING|02-10 04:14:25|SessionErrorInterceptor.retrieveSessionId|Trying to reconnect, due to error getting session id: SQL compilation error: error line 1 at position 7
invalid identifier 'CURRENT_SID'
SEVERE|02-10 04:14:26|SessionErrorInterceptor.retrieveSessionId|Error determining session id
net.snowflake.client.jdbc.SnowflakeSQLException: SQL compilation error: error line 1 at position 7
invalid identifier 'CURRENT_SID'
    at net.snowflake.client.jdbc.SnowflakeUtil.checkErrorAndThrowExceptionSub(SnowflakeUtil.java:153)
    at net.snowflake.client.jdbc.SnowflakeUtil.checkErrorAndThrowException(SnowflakeUtil.java:77)
    at net.snowflake.client.core.StmtUtil.pollForOutput(StmtUtil.java:503)
    at net.snowflake.client.core.StmtUtil.execute(StmtUtil.java:380)
    at net.snowflake.client.core.SFStatement.executeHelper(SFStatement.java:582)
    at net.snowflake.client.core.SFStatement.executeQueryInternal(SFStatement.java:266)
    at net.snowflake.client.core.SFStatement.executeQuery(SFStatement.java:202)
    at net.snowflake.client.core.SFStatement.execute(SFStatement.java:877)
    at net.snowflake.client.jdbc.SnowflakeStatementV1.executeQueryInternal(SnowflakeStatementV1.java:273)
    at net.snowflake.client.jdbc.SnowflakePreparedStatementV1.executeQuery(SnowflakePreparedStatementV1.java:181)
    
WARNING|02-10 04:14:26|SessionErrorInterceptor.createDecorator|Could not determine session information for statement: com.nielsen.datalink.common.jdbc.pool.SessionErrorInterceptor$StatementProxy[Proxy=243720187; Connection=ProxyConnection[PooledConnection[net.snowflake.client.jdbc.SnowflakeConnectionV1@22bf6bee]]; Delegate=net.snowflake.client.jdbc.SnowflakeStatementV1@c32145; Sql=null]
INFO|02-10 04:14:26|SessionErrorInterceptor$StatementProxy.invoke|[session=null] Executing SQL: 

select count(*) as total_record_count from RIM

WARNING|02-10 04:14:26|SessionErrorInterceptor$StatementProxy.invoke|Encountered SQL error: net.snowflake.client.jdbc.SnowflakeSQLException: Statement is closed.
    at net.snowflake.client.jdbc.SnowflakeStatementV1.raiseSQLExceptionIfStatementIsClosed(SnowflakeStatementV1.java:152)
    at net.snowflake.client.jdbc.SnowflakeStatementV1.executeUpdateInternal(SnowflakeStatementV1.java:214)
    at net.snowflake.client.jdbc.SnowflakeStatementV1.executeLargeUpdate(SnowflakeStatementV1.java:206)
    at net.snowflake.client.jdbc.SnowflakeStatementV1.executeUpdate(SnowflakeStatementV1.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    

Googled the exception and haven't found a single link.

I am also getting these error codes:[0A000, 200024]

This is my connection url:jdbc:snowflake://account.xxx.azure.snowflakecomputing.com/?db=DB_NAME&schema=SCHEMA_NAME&warehouse=WAREHOUSE&CLIENT_SESSION_KEEP_ALIVE=true

I am passing all valid names in the above URL and I am passing the correct username and password.

I am using JDK 1.8

Upvotes: 0

Views: 9369

Answers (2)

Greg Pavlik
Greg Pavlik

Reputation: 11046

When a query works fine on the Snowflake web UI and experiences issues when using a connector (JDBC, ODBC, Python, etc), one of the things to check is if something like a packet inspector on the network is interfering with HTTPS traffic from the connector. You can download and run SnowCD (connectivity diagnostics) to check on this.

https://docs.snowflake.com/en/user-guide/snowcd.html

If SnowCD reports any issues, you can run select system$allowlist(); to get a list of all DNS entries the network team will need to bypass from packet inspection.

https://docs.snowflake.com/en/sql-reference/functions/system_allowlist

Upvotes: 2

JohnnyUtah
JohnnyUtah

Reputation: 545

Anecdotal, but I got this error message when I was running the SQL query select count(*) as total_record_count from TABLE_NAME, but TABLE_NAME was a reserved SQL term called ORDER. I suspect that table name was what caused this error.

Upvotes: 0

Related Questions