Skip to content

DatabaseDriver swallows real exception #34728

@eduanb

Description

@eduanb

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions