1

我正在尝试连接到 Postgres,这是我收到的错误消息:

[main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost:5433/postgres
[main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=postgres, password=****}
[main] WARN org.hibernate.cfg.SettingsFactory - Could not obtain connection to query metadata
org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

我已在 hibernate.conf 中验证用户名/密码没问题

    <!-- Database connection settings -->
    <property name="connection.driver_class">org.postgresql.Driver</property>
    <property name="connection.url">jdbc:postgresql://localhost/postgres</property>
    <property name="connection.username">postgres</property>
    <property name="connection.password">*******</property>

这是我的 pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
# host   postgres,replication    localhost   127.0.0.1/32    md5
# host   postgres,replication    localhost   ::1/128     md5
host     all     all     0.0.0.0/0   md5

我在 Windows(不是 UNIX)上工作。所以请建议我如何解决这个问题。

谢谢!

4

1 回答 1

2

连接 url 中的端口号在哪里。jdbc:postgresql://localhost: portno/postgres

所以最终的 url 应该根据我的电脑上的数据库服务器端口

jdbc:postgresql://localhost:5432/postgres
于 2013-10-18T07:36:30.130 回答