我正在使用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
可能是什么问题?
答案 0 :(得分:0)
这些几乎总是防火墙问题或这些系统之间的某些其他程序或硬件。你可以像你一样禁用防火墙,或者最好通过SSH等隧道。隧道,因为它在安全方面提供较少的问题,绝对是可取的。如果失败,那么您可以将其作为网络问题进行故障排除。