brettwooldridge / HikariCP

光 HikariCP・A solid, high-performance, JDBC connection pool at last.
Apache License 2.0
19.91k stars 2.92k forks source link

Hikari + Snowflake + Oauth with token refresh #2183

Open rsdetoni opened 7 months ago

rsdetoni commented 7 months ago

Hi, Team Hikari =)

Guys I am having difficult to implement Hikari with snowflake, the problem is that I need to refresh the token and for that I use this suggestion:

https://blog.jdriven.com/2021/06/configure-hikari-connection-pool-when-using-rds-iam/

I just change a little bit because I am using azure, at the end i need to pass this properties:

    ctx = snowflake.connector.connect(
       user="<username>",
       host="<hostname>",
       account="<account_identifier>",
       authenticator="oauth",
       token="<external_oauth_access_token>",
       warehouse="test_warehouse",
       database="test_db",
       schema="test_schema"
    )

The first time worked great, but when the first token expire I am facing jdbc connection failed. My code is showing the refresh token correctly when max-lifetime is ended, and the getToken is called for getPassword.

My code is based on spring and I am using this annotations for generate only one Hikari by application, because I think Hikari don't support multithread with multi-instances, because of that I used the singleton annotation on a @Configuration:

     @Bean(name = "DataSource")
     @Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
     //Create datadource with configuration

Could you explain or give an example how to refresh token using this pool of connections. I am feeling that the old connections are stuck and we are not using the new ones

urosjarc commented 7 months ago

I'm also interested on how good and stable is snowflake support, if any?