#2397·HikariCP

Ensuring at least one connection is initialized before dependent framework bootstrap (Hibernate)

Author: janjicandjelka8Created Mar 27, 2026Updated Jun 6, 2026

Is there a recommended way in HikariCP to block application startup until at least one connection is successfully established?

Context:

Our custom Hibernate PhysicalNamingStrategy depends on JDBC metadata: @Override public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment context) { Identifier result = name; // replace table name postfix if not running with customer db user Identifier currentSchemaIdentifier = context.getCurrentSchema(); ...

During startup, Hibernate sometimes runs before a connection is available, so context.getCurrentSchema() falls back to the hibernate.default_schema, which is not the same as the currentSchema from an established JDBC connection (expected value is DB_CUSTOMER, which is in 99% cases correctly taken).

This is happening occasionally. Usually, restarting the Spring Boot app resolves the issue, and we assume it is a race condition between Hikari and Hibernate.

Would setting initializationFailTimeout, or any other configuration, guarantee that a connection is ready before consumers (like Hibernate) access it?

Hikari properties:

prefix: "spring.datasource.hikari", properties: { validationTimeout: 5000, hikariPoolMXBean: { }, minimumIdle: 10, password: "******", metricsTrackerFactory: { }, dataSourceProperties: { }, loginTimeout: 30, autoCommit: true, connectionTimeout: 30000, poolName: "DB_NAME", initializationFailTimeout: 1, readOnly: false, registerMbeans: false, healthCheckProperties: { }, isolateInternalQueries: false, leakDetectionThreshold: 0, maxLifetime: 1800000, keepaliveTime: 120000, allowPoolSuspension: false, idleTimeout: 600000, driverClassName: "oracle.jdbc.OracleDriver", jdbcUrl: "jdbc:oracle:thin:@ldap://ldap01.abc.net:389/DB_NAME,cn=OracleContext,...", maximumPoolSize: 10, username: "DB_CUSTOMER"

Hibernate default schema property: spring.jpa.properties.hibernate.default_schema: "DEFAULT_SCHEMA" (this must stay as is)

Source: brettwooldridge/HikariCP