0

My springboot microservice depends on AS400 DB2 which may be down when the service starts up. The service has a configuration bean which has autowired JpaRepository based repositories. During startup, when DB2 is down I get following message:

"org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set"

So the services fails to start up and remains dead till forcefully rebooted.

If I set JVM parameter "-Dhibernate.dialect=org.hibernate.dialect.DB2400Dialect", the service starts up and I can make requests to the service when DB2 comes up. It feels like a hack, so I wonder if there is the right way to deal with this issue for springboot services?

I saw this thread, but it doesn't answer my question. Basically what I am looking for is somehow start the microservice with those autowired repositories even if DB is down at the moment so that later, when the actual request comes, the connection to the DB could be restored and request serviced.

Community
  • 1
  • 1
Andrei
  • 175
  • 1
  • 9

1 Answers1

1

Have you tried to specify Hibernate dialect for your DBMS flavour in src/main/resources/application.properties like:

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.DB2400Dialect

? Spring Boot autodetects dialect on startup if database is up but there is nothing inappropriate to specify your dialect explicitly in source code.

Alexander Yanyshin
  • 1,310
  • 10
  • 8
  • Yes, it did. but by the time it gets to JDBC layer, the property is not there. Also the dialect gets obtained from the live connection when not specified. – Andrei Dec 21 '16 at 23:13