Guest User

Untitled

a guest
May 13th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. public class PostgreSQLJDBC {
  2. public static void main(String args[]) {
  3. System.out.println("looking for db connection");
  4. Connection c = null;
  5. try {
  6. Class.forName("org.postgresql.Driver");
  7. c = DriverManager //139.59.175.170 eller 127.0.0.1/32
  8.  
  9. .getConnection("jdbc:postgresql://178.62.33.183:5432/steinar");
  10. } catch (SQLException e) {
  11. System.out.print("sql exception thrown ");
  12. e.printStackTrace();
  13. System.err.println(e.getClass().getName()+": "+e.getMessage());
  14. System.exit(0);
  15. }
  16. catch (ClassNotFoundException e){
  17. e.printStackTrace();
  18. }
  19. System.out.println("Opened database successfully");
  20. }
  21. }
  22.  
  23. FATAL: no pg_hba.conf entry for host "ip", user "user", database "db",
  24.  
  25. Connection to 178.62.33.183:5432 refused.
  26. Check that the hostname and port are
  27. correct and that the postmaster is
  28. accepting TCP/IP connections.
  29.  
  30. # IPv4 local connections:
  31. host all myUserName myIp trust
  32.  
  33. psql: could not connect to server: No such file or directory
  34. Is the server running locally and accepting
  35. connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Add Comment
Please, Sign In to add comment