英文:
Activating warehouse in Snowflake using Java and spark
问题
我正在尝试连接到Snowflake数据库并激活特定的仓库。我已经在JDBC连接中和属性中都使用了仓库。
在JDBC连接中:
jdbc:snowflake://xy12345.eu-central-1.snowflakecomputing.com/?warehouse=mywh
以及在属性中:
options.put("warehouse", "mywh")
是否还需要添加其他内容。
即使我提供了一个不正确的仓库,连接也会通过,这是不正确的。我是否漏掉了什么,或者有没有办法通过Spark执行 "use warehouse mywh"。
谢谢。
英文:
I am trying to connect to snowflake DB and activate a particular warehouse.I have used warehouse in both JDBC connection
jdbc:snowflake://xy12345.eu-central-1.snowflakecomputing.com/?warehouse=mywh
as well as in the properties
options.put("warehouse", "mywh")
Is there anything else that needs to be added .
Even if I am giving an incorrect warehouse , the connection goes through which is not right .
Am I missing anything or is there anyway to execute "use warehouse mywh" through spark .
Thanks
答案1
得分: 0
你可以执行命令 - 使用游标来更改仓库的使用 - 使用仓库
英文:
Can you execute command - USE WAREHOUSE <name> using cursor to change the warehouse usage.
答案2
得分: 0
使用JDBC中的warehouse参数,或者在属性中提供它,就足以使用该warehouse。混淆在于JDBC驱动程序如何连接到Snowflake。
使用JDBC连接到Snowflake时,JDBC驱动程序不会立即运行"USE WAREHOUSE"命令。这就是为什么在连接时不会出现任何错误,即使你输入了错误的warehouse。
当你尝试执行SQL查询时,如果需要一个活动的warehouse,就会使用你选择的warehouse。如果你输入了错误的warehouse,你会收到类似以下内容的错误:
Exception in thread "main" net.snowflake.client.jdbc.SnowflakeSQLException: 在当前会话中未选择活动warehouse。请使用"use warehouse"命令选择活动warehouse。
英文:
Using the warehouse parameter on JDBC, or giving it in the properties are enough to use that warehouse. The confusion is about how JDBC driver connects to Snowflake.
When you connect to Snowflake with JDBC, JDBC driver does not run "USE WAREHOUSE" immediately. This is why you do not get any error while connecting, even you entered a wrong warehouse.
When you try to execute a SQL query, if it requires an active warehouse, the warehouse you picked will be used. In case, you entered a wrong warehouse, you get an error something like this:
Exception in thread "main" net.snowflake.client.jdbc.SnowflakeSQLException: No active warehouse selected in the current session. Select an active warehouse with the 'use warehouse' command.
专注分享java语言的经验与见解,让所有开发者获益!
评论