With a Spring Data JDBC application and this config (everything is correct except for the password):
spring:
datasource:
url: jdbc:postgresql://localhost:5432/my-db
password: wrong-password
username: real-user
The app fails to startup with this error message:
Caused by: java.lang.IllegalStateException: Unable to detect database type
This error makes the user think they must add spring.datasource.type or even spring.datasource.driver-class-name properties, but neither will solve it.
After further investigation, the root cause in DatabaseDriver:324 is swallowed and not reported to the user. Adding a breakpoint, I can see that the root cause is in fact:
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "real-user"
It seems like the swallow was intentional so the type can be DatabaseDriver.UNKNOWN. It is very misleading to the user so I would suggest that propagating the error and having startup fail because of the PSQLException is much better than the IllegalStateException.
With a Spring Data JDBC application and this config (everything is correct except for the password):
The app fails to startup with this error message:
Caused by: java.lang.IllegalStateException: Unable to detect database typeThis error makes the user think they must add
spring.datasource.typeor evenspring.datasource.driver-class-nameproperties, but neither will solve it.After further investigation, the root cause in DatabaseDriver:324 is swallowed and not reported to the user. Adding a breakpoint, I can see that the root cause is in fact:
It seems like the swallow was intentional so the type can be
DatabaseDriver.UNKNOWN. It is very misleading to the user so I would suggest that propagating the error and having startup fail because of thePSQLExceptionis much better than theIllegalStateException.