Guest User

Untitled

a guest
Feb 8th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. import java.sql.*;
  2. import java.util.Properties;
  3.  
  4. public class Main {
  5. public static void main(String[] args) {
  6. try {
  7. Class.forName("org.postgresql.Driver");
  8. String url = "jdbc:postgresql://localhost:5432/Test";
  9. Properties props = new Properties();
  10. props.setProperty("user","postgre");
  11. props.setProperty("password","3333");
  12. Connection conn = DriverManager.getConnection(url, props);
  13. }
  14. catch (ClassNotFoundException e) {
  15. System.out.println("PostgreSQL JDBC driver not found.");
  16. e.printStackTrace();
  17. }
  18. catch (SQLException e) {
  19. System.out.println("Connection failure.");
  20. e.printStackTrace();
  21. }
  22. }
  23. }
  24.  
  25. Connection failure.
  26. 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)
  27. at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:514)
  28. at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:141)
  29. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192)
  30. at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
  31. at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
  32. at org.postgresql.Driver.makeConnection(Driver.java:454)
  33. at org.postgresql.Driver.connect(Driver.java:256)
  34. at java.sql.DriverManager.getConnection(DriverManager.java:664)
  35. at java.sql.DriverManager.getConnection(DriverManager.java:208)
  36. at Main.main(Main.java:13)
  37.  
  38. Process finished with exit code 0
Add Comment
Please, Sign In to add comment