The following are some of the reasons for the hibernate.dialect
not set issue.
Most of these exceptions are shown in the startup log which is finally followed by the mentioned issue.
Example: In Spring boot app with Postgres DB
1. Check if the database is actually installed and its server is started.
- org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
- java.net.ConnectException: Connection refused: connect
- org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
2. Check if the database name is correctly mentioned.
org.postgresql.util.PSQLException: FATAL: database "foo" does not exist
In application.properties
file,
spring.datasource.url = jdbc:postgresql://localhost:5432/foo
but foo
didn't exist.
So I created the database from pgAdmin for postgres
CREATE DATABASE foo;
3. Check if the host name and server port is accessible.
- org.postgresql.util.PSQLException: Connection to localhost:5431 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
- java.net.ConnectException: Connection refused: connect
4. Check if the database credentials are correct.
- as @Pankaj mentioned
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "postgres"
spring.datasource.username= {DB USERNAME HERE}
spring.datasource.password= {DB PASSWORD HERE}