Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
- }
- }
- }
- 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
Add Comment
Please, Sign In to add comment