0

I have a procedure that required config param from session using current_settings("domainid", "123"). that I need to set into session of HikariDataSource but through yml.

I have tried below ways to set into yml but its not working

  1. Set into datasource: datasource.connectionProperties: domainid=123

  2. Set into hikari
    datasource.hikari data-source-properties: domainid:123

  3. Set into datasource tomcat

    datasource.tomcat.connection-properties:domainid=123

I am using spring boot 2.3.5 release versiin. let me know if anyone has idea. thanks in advance

I can't set below set connection property to yml public class TenantAwareHikariDataSource extends HikariDataSource {

@Override
public Connection getConnection() throws SQLException {
    Connection connection = super.getConnection();

    try (Statement sql = connection.createStatement()) {
        sql.execute("SET app.current_tenant = '" + ThreadLocalStorage.getTenantName() + "'");
    }

    return connection;
}

@Override
public Connection getConnection(String username, String password) throws SQLException {
    Connection connection = super.getConnection(username, password);

    try (Statement sql = connection.createStatement()) {
        sql.execute("SET app.current_tenant = '" + ThreadLocalStorage.getTenantName() + "'");
    }

    return connection;
}

}

Beta Z
  • 1
  • 1
  • Please show what you mean by (session) here. Some some code of how you are using session, how you are creating a HikariDataSource, etc – JCompetence Apr 05 '22 at 09:34
  • I have defined Hikari datasource into yml only. and autowired datasource – Beta Z Apr 05 '22 at 10:22
  • Is this what you are after https://stackoverflow.com/questions/26490967/how-do-i-configure-hikaricp-in-my-spring-boot-app-in-my-application-properties-f ? – JCompetence Apr 05 '22 at 10:24

0 Answers0