Impossibile connettersi al database Postgres su Azure con Java

Sep 23 2020

Ho creato un database Postgres su Azure seguendo le istruzioni di https://docs.microsoft.com/en-us/azure/postgresql/connect-java. Ora posso connettermi al database tramite il mio PgAdmin locale e anche da terminale con psql. Tuttavia, quando provo a connettermi con Hibernate (versione 5.4.21) nel mio codice java (java 8) ottengo sempre il seguente errore senza alcuna spiegazione.

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

Ho provato diverse opzioni di modalità SSL ma senza successo. Ho anche disabilitato SSL dal lato Azure, ma ancora senza successo. Qualcuno può aiutarmi a risolvere questo problema?

Risposte

2 JacobStampeMikkelsen Sep 23 2020 at 20:57

Abbiamo avuto lo stesso problema con la 42.2.15versione del driver. Prova a impostare

gssEncMode=disable

Leggi di più: https://gitmemory.com/issue/pgjdbc/pgjdbc/1868/683710515