0

First: this is not a duplicate question.

More than 4.5 years ago another user wrote (on Stackoverflow.com) that he had a requirement where his Spring Boot Application should be able to start even when database is down. He used Spring Boot Application 1 with Hibernate 4. I now have the same problem with Spring Boot Application 2 with Hibernate 5. I tried to apply the checked answer for Hibernate 4, but this doesn't work for my application.

Is it still possible to start it without depending on database? Here are the (edited) Hibernate 5-properties (application.yml):

spring:
  datasource:
    url: jdbc:mysql://localhost/schema?serverTimezone=UTC
    username: root
    password: root
    continue-on-error: true
    initialization-mode: never
    tomcat:
      initial-size: 0
      time-between-eviction-runs-millis: 5000
      min-evictable-idle-time-millis: 5000
      min-idle: 0
  jpa:
    show-sql: true
    hibernate:
      ddl-auto: none
    properties:
      hibernate:   
        dialect: org.hibernate.dialect.MySQL5Dialect
        hbm2ddl:
          auto: none
        temp:
          use_jdbc_metadata_defaults: false

My question has been marked as "possible duplicate". The provided possible answer is not a possible answer at all. As I wrote, I am demanded (it is a REQUIREMENT) not to use ANY OTHER DATABASE, EVEN H2. So, the problem is the EntityManagerFactory Bean (together with data source); if it fails to be created, the application fails to start. That's it.

LowLevel
  • 1,085
  • 1
  • 13
  • 34
  • Nope. It has nothing to do with ODBC-JDBC bridge. It is about the Entity Manager Factory Bean. If it fails to be created, the application fails as well. – LowLevel Feb 28 '19 at 14:23
  • As the other user says I am REQUIRED NOT TO USE ANY DATABASE, EVEN H2 – LowLevel Feb 28 '19 at 14:23

1 Answers1

0

I know this question is quite old but I solved this problem this way (for people working with Hikari).

I added these two lines to application.properties:

spring.datasource.hikari.initialization-fail-timeout=-1
spring.datasource.hikari.connection-timeout=0

Well first line is for me obvious with documentation of Hikari (https://github.com/brettwooldridge/HikariCP). It is written that for the second line allowed values are between 250-*. But I used value of zero and it started to work as I expected.