skip to Main Content

Hello guys, I am running into this error on my first trial on springboot, and the exception message makes no sense to me, the error message is as follows:

2022-10-03 22:27:15.801 ERROR 22836 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.

org.postgresql.util.PSQLException: ��������: ���ݿ� "db_name" ������
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2675) ~[postgresql-42.3.7.jar:42.3.7]
    at org.postgresql.core.v3.QueryExecutorImpl.readStartupMessages(QueryExecutorImpl.java:2787) ~[postgresql-42.3.7.jar:42.3.7]
    at org.postgresql.core.v3.QueryExecutorImpl.<init>(QueryExecutorImpl.java:173) ~[postgresql-42.3.7.jar:42.3.7]
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:290) ~[postgresql-42.3.7.jar:42.3.7]
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.3.7.jar:42.3.7]
    at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:223) ~[postgresql-42.3.7.jar:42.3.7]
    at org.postgresql.Driver.makeConnection(Driver.java:402) ~[postgresql-42.3.7.jar:42.3.7]

And my application.properties is like this:
server.port=5432
spring.datasource.url=jdbc:postgresql://localhost:5432/db_name
spring.datasource.username=postgres
spring.datasource.password=password

spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgresSQLDialect
spring.jpa.properties.hibernate.format_sql=true

2

Answers


  1. You have the same port, because PostgreSQL is using port 5432, server.port is to install the port for spring to run, you can change server.port to another port eg: 80, 8080,…
    you should add this line to your configuration to load the PostgreSQL driver

    spring.datasource.driver-class-name=org.postgresql.Driver
    

    The last line should be changed to the following:

    spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
    
    Login or Signup to reply.
  2. try this properties:

    spring.jpa.hibernate.ddl-auto=update
    spring.jpa.generate-ddl=true
    spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation= true
    spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
    
    spring.datasource.url=jdbc:postgresql://localhost:5432/<database name>
    spring.datasource.username=postgres
    spring.datasource.password=<db password>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search