【问题标题】:Unable to connect to "Compose for PostgreSQL" DB created in bluemix through eclipse无法通过 eclipse 连接到在 bluemix 中创建的“Compose for PostgreSQL”数据库
【发布时间】:2021-09-10 00:07:48
【问题描述】:

我无法使用 Eclipse 建立与 Compose for PostgreSQL DB 服务的连接。测试连接时出现以下错误。

org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. 
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:122) 
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:65) 
    at org.postgresql.jdbc2.AbstractJdbc2Connection.(AbstractJdbc2Connection.java:116) 
    at org.postgresql.jdbc3.AbstractJdbc3Connection.(AbstractJdbc3Connection.java:30) 
    at org.postgresql.jdbc3.Jdbc3Connection.(Jdbc3Connection.java:24) 
    at org.postgresql.Driver.makeConnection(Driver.java:369) 
    at org.postgresql.Driver.connect(Driver.java:245) 
    at org.eclipse.datatools.enablement.internal.postgresql.PostgreSQLJDBCConnection.createConnection(PostgreSQLJDBCConnection.java:87) 
    at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:105) 
    at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:54) 
    at org.eclipse.datatools.enablement.internal.postgresql.PostgreSQLJDBCConnection.(PostgreSQLJDBCConnection.java:47) 
    at org.eclipse.datatools.enablement.internal.postgresql.PostgreSQLConnectionFactory.createConnection(PostgreSQLConnectionFactory.java:51) 
    at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:83) 
    at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:359) 
    at org.eclipse.datatools.connectivity.ui.PingJob.createTestConnection(PingJob.java:76) 
    at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:59) 
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) 
Caused by: java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) 
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)

我能够通过部署在 BlueMix 中的应用程序连接到数据库。

【问题讨论】:

    标签: postgresql ibm-cloud compose-db


    【解决方案1】:

    您如何填充连接凭据?该应用程序在 Bluemix 上运行时将有权访问 VCAP_SERVICES,但除非您专门将该环境变量复制到您的 Eclipse 环境,否则您的应用程序将无法使用该信息。

    【讨论】:

    • 我正在使用 CF cli 命令“cf env ”来获取服务详情。以下是我在 eclipse 中输入的连接详情。 Driver: PostgreSQL JDBC Driver, Database: , URL: jdbc:postgresql://:/ username:, password: 是否需要添加任何其他详细信息以便连接。
    【解决方案2】:

    错误表明连接被拒绝。这很可能意味着您输入的主机和端口组合不正确。您需要确保可以连接到主机。

    您可以通过执行nc -vz xxxxx.dblayer.com 10000 来检查您的本地系统是否可以连接,其中xxxxx.dblayer.com 是在变量中提供给您的完整主机名,10000 是端口,也提供了。

    似乎您的语法/配置可能不正确,因为连接被拒绝表明它无法连接,但是从您的帖子中并不清楚它实际尝试连接的主机名/端口。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-10
      • 2018-04-08
      • 2020-05-05
      • 1970-01-01
      • 1970-01-01
      • 2018-12-21
      • 2019-11-06
      相关资源
      最近更新 更多