我尝试使用 HikariCP 连接池通过 JDBC 连接雪花。我使用 Spring Boot 配置 XML 文件来创建 bean。我有用于身份验证的私钥。所以我尝试了以下方法,
属性文件:
snowflake.url=jdbc:snowflake://{account_name}.snowflakecomputing.com/?warehouse=${snowflake.warehouse}&db=${snowflake.database}&schema=${snowflake.schema}&role=${snowflake.role}
Spring 配置 XML:
<bean id="dbUtil" class="utilities.DbUtils">
<constructor-arg>
<bean id="snowflakeDataSource" class="com.zaxxer.hikari.HikariDataSource">
<property name="driverClassName" value="net.snowflake.client.jdbc.SnowflakeDriver"/>
<property name="jdbcUrl" value="${snowflake.url}"/>
<property name="username" value="${snowflake.user}"/>
<property name="dataSourceProperties">
<props>
<prop key="privateKeyFile">${snowflake.privateKeyPath}</prop>
<prop key="privateKeyPassphrase">${snowflake.privateKeyPassphrase}</prop>
</props>
</property>
</bean>
</constructor-arg>
</bean>
当尝试使用具有上述配置的 commonsdbUtils 库执行查询时,它会抛出以下错误:
HikariPool-1 - Exception during pool initialization.
net.snowflake.client.jdbc.SnowflakeSQLLoggedException: Missing password.
at net.snowflake.client.jdbc.DefaultSFConnectionHandler.initialize(DefaultSFConnectionHandler.java:117)
at net.snowflake.client.jdbc.DefaultSFConnectionHandler.initializeConnection(DefaultSFConnectionHandler.java:85)
at net.snowflake.client.jdbc.SnowflakeConnectionV1.initConnectionWithImpl(SnowflakeConnectionV1.java:116)
at net.snowflake.client.jdbc.SnowflakeConnectionV1.<init>(SnowflakeConnectionV1.java:96)
at net.snowflake.client.jdbc.SnowflakeDriver.connect(SnowflakeDriver.java:180)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:121)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:100)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
at org.apache.commons.dbutils.AbstractQueryRunner.prepareConnection(AbstractQueryRunner.java:319)
at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:327)
我也面临着同样的问题,你得到解决了吗@saravanan