Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. try {
  2.  
  3.         Class.forName("org.postgresql.Driver");
  4.  
  5.         } catch (ClassNotFoundException e) {
  6.             e.printStackTrace();
  7.  
  8.         }
  9.          
  10.         Connection connection = null;
  11.  
  12.         try {
  13.  
  14.         connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres", "postgres", "admin");
  15.  
  16.         } catch (SQLException e) {
  17.  
  18.         System.out.println("Connection Failed! Check output console");
  19.         e.printStackTrace();
  20.         return;
  21.  
  22.         }
  23.          
  24.         System.out.println("connected");
  25.        
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement