Home > Software engineering >  How to use HikariPool to connect to Snowflake - SpringBoot, Gradle
How to use HikariPool to connect to Snowflake - SpringBoot, Gradle

Time:10-18

I am trying to connect to Snowflake using HikariPool. I am using SpringBoot and Gradle.

I added these dependencies to Gradle

implementation group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc'
implementation 'net.snowflake:snowflake-jdbc:3.12.16'
implementation group: 'com.zaxxer', name: 'HikariCP', version: '5.0.0'

And config file looks like this:

@Slf4j
@Configuration
public class SnowflakeRepositoryConfig {

    @Bean
    JdbcTemplate jdbcTemplate(@Value("${repository.snowflake.url}") String jdbcUrl,
                              @Value("${repository.snowflake.user}") String user,
                              @Value("${repository.snowflake.password}") String password){
        
        log.info("-----Configuring JDBCTemplate------");
        HikariConfig config = new HikariConfig();
        config.setDriverClassName("net.snowflake.client.jdbc.SnowflakeDriver");
        config.setJdbcUrl(jdbcUrl);
        config.setUsername(user);
        config.setPassword(password);
        HikariDataSource ds = new HikariDataSource(config);

        return new JdbcTemplate(ds);
    }
}

Application.yml

repository:
  snowflake:
    url: jdbc:snowflake://nw99383.eu-west-2.snowflakecomputing.com/?db=TEST_DB&warehouse=SF_TUTS_WH&schema=PUBLIC&tracing=ALL
    user: ****
    password: ****

And I am getting following error:

13:56:42.353 [main] ERROR net.snowflake.client.core.HttpUtil - Response status line reason: Forbidden
13:56:42.358 [main] ERROR net.snowflake.client.core.HttpUtil - Response content: <html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
</body>
</html>

13:56:43.371 [main] ERROR com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Exception during pool initialization.
net.snowflake.client.jdbc.SnowflakeSQLException: JDBC driver encountered communication error. Message: HTTP status=403.

CodePudding user response:

Could you please update Snowflake account URL and try: nw99383.eu-west-2.aws.snowflakecomputing.com/

  • Related