Search code examples
javapostgresqlspring-bootmacos

Idea is trying to connect to the database by a name that I did not specify


error:

org.hibernate.exception.GenericJDBCException: unable to obtain isolated JDBC connection [FATAL: password authentication failed for user "andrew"] [n/a]

application.property:

spring.datasource.name=postgres
spring.datasource.password=123

spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true

I use spring 3.4.3 and java 21 in the application.

They work on a mac and I don't understand where and why idea uses the name of my laptop as the user, and not what I specified in the properties. Although everything passes the test connect. This was not the case on other projects.

processes on the prosthesis 5432:

andrew@MacBook-Air-Andrey-2 ~ % sudo lsof -i :5432           
Password:
Sorry, try again.
Password:
COMMAND   PID     USER   FD   TYPE   SIZE/OFF NODE NAME
postgres  310 postgres    7u  IPv6   0t0  TCP *:postgresql (LISTEN)
postgres  310 postgres    8u  IPv4   0t0  TCP *:postgresql (LISTEN)
Python   1034   andrew   11u  IPv6   0t0  TCP localhost:50478->localhost:postgresql (ESTABLISHED)
Python   1034   andrew   12u  IPv6  0t0  TCP localhost:50479->localhost:postgresql (ESTABLISHED)
Python   1034   andrew   13u  IPv6  0t0  TCP localhost:50480->localhost:postgresql (ESTABLISHED)
postgres 1687 postgres   11u  IPv6  0t0  TCP localhost:postgresql->localhost:50478 (ESTABLISHED)
postgres 1688 postgres   11u  IPv6  0t0  TCP localhost:postgresql->localhost:50479 (ESTABLISHED)
postgres 1689 postgres   11u  IPv6  0t0  TCP localhost:postgresql->localhost:50480 (ESTABLISHED)

I tried to clear the cache, restart the project


Solution

  • spring.datasource.name doesn't specify the username, use spring.datasource.username for this.

    spring.datasource.username=postgres
    

    spring.datasource.name specifies the name of the database to use, especially used when using an embedded database like H2 or Derby.