Asraar Wani
Asraar Wani

Reputation: 70

Unable to execute Snowflake COPY Command through Java

I am unable to load data from a stage on SnowFlake using java.

I don't see any errors but data is not loaded from stage "mystage" to table "TESTTABLE " Code:

Connection connection =  DriverManager.getConnection(connectionUrl, _connectionProperties);
        Statement statement = connection.createStatement();
        statement.executeQuery("copy into TESTTABLE (id, name) from (select $1, $2 from @mystage/F.csv.gz t);");

If I run same command in SnowFlake console, data is getting loaded into table "TESTTABLE " properly.

Upvotes: 1

Views: 355

Answers (2)

Asraar Wani
Asraar Wani

Reputation: 70

By mistake I had comment out connection.commit(); that was the problem.

Upvotes: 0

Lukasz Szozda
Lukasz Szozda

Reputation: 175726

We do not know to which database/schema the default connection points to. I would try to use fully qualified table name:

statement.executeQuery("copy into <db_name>.<schema_name>.TESTTABLE (id, name) from (select $1, $2 from @mystage/F.csv.gz t);");

Upvotes: 1

Related Questions