gpt4 book ai didi

java - 无法使用 Java 连接到 Azure 上的 Postgres 数据库

转载 作者:行者123 更新时间:2023-12-04 22:39:17 25 4
gpt4 key购买 nike

我按照 https://learn.microsoft.com/en-us/azure/postgresql/connect-java 中的说明在 Azure 上创建了一个 Postgres 数据库。 。现在我可以通过本地 PgAdmin 连接到数据库,也可以使用 psql 从终端连接到数据库。但是,当我尝试在 java 代码(java 8)中连接 Hibernate(版本 5.4.21)时,我总是收到以下错误,而没有任何解释。

org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:315)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:225)
at org.postgresql.Driver.makeConnection(Driver.java:465)
at org.postgresql.Driver.connect(Driver.java:264)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at test.ui.V9.main(V9.java:17)
Caused by: java.io.EOFException
at org.postgresql.core.PGStream.receiveChar(PGStream.java:443)
at org.postgresql.core.v3.ConnectionFactoryImpl.enableGSSEncrypted(ConnectionFactoryImpl.java:436)
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:144)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:213)
... 7 more

我尝试了不同的 SSL 模式选项,但没有成功。我还从 Azure 端禁用了 SSL,但仍然没有成功。有人可以帮我解决这个问题吗?

最佳答案

我们在 42.2.15 版本的驱动程序中遇到了同样的问题。尝试设置

gssEncMode=disable

了解更多:https://gitmemory.com/issue/pgjdbc/pgjdbc/1868/683710515

关于java - 无法使用 Java 连接到 Azure 上的 Postgres 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64016297/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com