Google Cloud Postgres服务器连接问题

时间:2018-03-06 14:13:52

标签: postgresql google-cloud-platform google-cloud-datastore google-cloud-sql wildfly-10

我得到了"Could not obtain connection to query metadata : Cannot create Poolable ConnectionFactory (Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.)" 当我尝试通过我的代码连接到Postgress时,

我尝试通过这个命令通过ssh连接它连接

gcloud beta sql connect instance_name --user=USER

但是当我尝试通过普通的PSQL命令连接时,它会给出连接TimeOut。 Google Cloud SQL Connection在运行超过5天的过程中突然停止。

我正在尝试连接

<beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <beans:property name="driverClassName" value="org.postgresql.Driver" />
    <beans:property name="url"
        value="jdbc:postgresql://databaseip:5432/db" />
    <beans:property name="username" value="user" />
    <beans:property name="password" value="password" />
</beans:bean>

请帮我正确连接,让我们知道是什么问题 我正在使用PostgreSQL 9.6 和谷歌云 wildfly-10.1.0。最终服务器,托管在谷歌云服务器的内部IP中

1 个答案:

答案 0 :(得分:1)

Cloud SQL实例的最大连接数取决于实例层limit。如果您的设置在之前工作并突然停止,则可能达到此限制。您可以使用&#34;连接池&#34;描述here的方法来管理SQL实例中的大量连接。

另外,如公开documentation中所述,请确保您已授权您尝试访问SQL实例的外部应用程序的IP地址,并且您没有使用专用网络IP。