I'm using a PostgreSQL 13 database on a Windows 10 System, and I'm trying to connect to it using Java and the JDBC driver, but I keep getting errors and I have no clue what the problem might be.
This is my code:
static String url = "jdbc:postgresql://localhost:5432/NIRONDB";
static String user = "postgres";
static String password = "#C3T\\<L[q^.G~QnSXrn";
Properties props = new Properties();
public static void enterEvent(int price,int maxAttendees,int hostID,int minAge,String
title,String location,String userInfo, String date, String time){
try {
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection(url, user, password);
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from user");
} catch (SQLException | ClassNotFoundException ex) {
Logger lgr = Logger.getLogger(DBHandler.class.getName());
lgr.log(Level.SEVERE, ex.getMessage(), ex);
}
}
And this is the error I get:
org.postgresql.util.PSQLException: Der Authentifizierungstyp 10 wird nicht unterstützt. Stellen Sie
sicher, dass die Datei 'pg_hba.conf' die IP-Adresse oder das Subnetz des Clients enthält und dass
der Client ein Authentifizierungsschema nutzt, das vom Treiber unterstützt wird.
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:504)
at
org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:173)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:136)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:29)
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:21)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:31)
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:410)
at org.postgresql.Driver.connect(Driver.java:280)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
I have no clue what I'm doing wrong.