79374261

Date: 2025-01-21 11:51:43
Score: 0.5
Natty:
Report link

It looks like the default database is optional, but I haven't tested.

You could defer the datasource connection on the first statement with LazyConnectionDataSourceProxy. It is a proxy for your datasource that will lazy initialize underlying JDBC connection (and thus defer everything that depends on it).

This article have a different use case, but they are combining AbstractRoutingDataSource with LazyConnectionDataSourceProxy, I believe this is what you are looking for.

The other option is to play with JPA bootstrap mode, but in this case, you will have to wait for each JDBC connection to be resolved in the pool and the EntityManagerFactory to be initialized.

Reasons:
  • Blacklisted phrase (1): This article
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Julien Antony