我正在使用 Spring 应用程序连接到 Postgresql 服务器(8.4 版)。
我的连接参数是:
<Environment name="/db/driver_class" value="org.postgresql.Driver" type="java.lang.String" override="false" />
<Environment name="/db/jdbc_url" value="jdbc:postgresql://test.server.com:5432/dev_database" type="java.lang.String" override="false" />
<Environment name="/db/user" value="user" type="java.lang.String" override="false" />
<Environment name="/db/password" value="password" type="java.lang.String" override="false" />
这些参数是正确的(我可以使用例如 PgAdminn 进行连接),但我仍然收到org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
错误消息。
检查数据库日志时,它似乎成功地授权了连接尝试:
LOG: 00000: connection authorized: user=user database=dev_database
LOCATION: BackendInitialize, postmaster.c:3352
LOG: 00000: connection authorized: user=user database=dev_database
LOCATION: BackendInitialize, postmaster.c:3352
LOG: 00000: connection authorized: user=user database=dev_database
LOCATION: BackendInitialize, postmaster.c:3352
LOG: 00000: connection received: host=lyys.server.com port=51279
LOCATION: BackendInitialize, postmaster.c:3274
LOG: 00000: connection received: host=lyys.server.com port=51280
LOCATION: BackendInitialize, postmaster.c:3274
LOG: 00000: connection authorized: user=user database=dev_database
LOCATION: BackendInitialize, postmaster.c:3352
LOG: 00000: connection authorized: user=user database=dev_database
LOCATION: BackendInitialize, postmaster.c:3352
可能是什么问题呢?