Trying to connect to the database. jar file is connected as a library. Here is the connection

import java.sql.*; import java.util.Properties; public class Main { public static void main(String[] args) { try { Class.forName("org.postgresql.Driver"); String url = "jdbc:postgresql://localhost:5432/Test"; Properties props = new Properties(); props.setProperty("user","postgre"); props.setProperty("password","3333"); Connection conn = DriverManager.getConnection(url, props); } catch (ClassNotFoundException e) { System.out.println("PostgreSQL JDBC driver not found."); e.printStackTrace(); } catch (SQLException e) { System.out.println("Connection failure."); e.printStackTrace(); } } } 

As a result, the following crashes:

 Connection failure. org.postgresql.util.PSQLException: ВАЖНО: пользователь "postgre" не прошёл проверку подлинности (по паролю) (pgjdbc: autodetected server-encoding to be windows-1251, if the message is not readable, please check database logs and/or host, port, dbname, user, password, pg_hba.conf) at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:514) at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:141) at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192) at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195) at org.postgresql.Driver.makeConnection(Driver.java:454) at org.postgresql.Driver.connect(Driver.java:256) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:208) at Main.main(Main.java:13) Process finished with exit code 0 

I tried to conjure with the encoding, but in the end I did not understand. help me please

  • How to help you fix a password error? - Roman C
  • @RomanC think it is in the password, I mean the password is correct, I checked it with the database, but from idea it does not want to connect - Dima Vasilyev
  • I had such a problem, I had to add credits to the database and it all worked. - Roman C

0