Satyajit Sarkar
Satyajit Sarkar

Reputation: 11

Unable to execute Snowflake PUT Command through Java

We are trying to load JSON files using Java from a file location to Snowflake Named Stage. Currently, the PUT command only works for ODBC and not JDBC. So is there any way to execute PUT command using Java code?

Thanks

Upvotes: 1

Views: 1159

Answers (1)

user13472370
user13472370

Reputation:

The Snowflake JDBC Driver does support use of PUT statements for local file uploads. The following java statement is considered a valid query and the file is uploaded:

statement.executeQuery("PUT file:///tmp/foo.json @JSONSTAGE/ overwrite=true");

Running it under a logger produces logs such as the following (logs here are from JDBC driver version v3.12.2):

n.s.c.jdbc.SnowflakeFileTransferAgent$1 FINE call:778 - filePath: /tmp/foo.json
n.s.c.jdbc.SnowflakeFileTransferAgent FINE uploadFiles:1751 - Done with uploading

The JDBC driver also supports a more efficient way of uploading a stream directly, documented here.

Upvotes: 2

Related Questions