Skip to content
Advertisement

Spring boot – Snowflake JDBC – Alter session automatically when application loads

I’m trying to connect Snowflake to Spring boot based application. Everything works well however due to some crazy defaults in snowflake, I’m having to deal with the below error: https://community.snowflake.com/s/article/SAP-BW-Java-lang-NoClassDefFoundError-for-Apache-arrow

I can fire the queries via Spring data JPA but not able to map the results at all. The solution asks for changing the default resultset format from ARROW to JSON:

Customer can use this property (jdbc_query_result_format=json) in datasouce property of Application server or session property in application like

Statement = connection.createStatement();
Statement.executeQuery("ALTER SESSION SET JDBC_QUERY_RESULT_FORMAT='JSON'");

I’m just wondering how could I achieve that with Spring ie. run the above SQL in the bootstrap period. I’m using Spring data JPA queries.

Advertisement

Answer

The parameter JDBC_QUERY_RESULT_FORMAT can be set per account/user/session, therefore if you always want to have JSON for that user you can set it directly via Snowflake UI only once:

ALTER USER <youruser> SET JDBC_QUERY_RESULT_FORMAT='JSON';

This would only impact your user and the account would still have ARROW as default. And you wouldn’t need to set it at session level all the time.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement