Advertisement
Guest User

Untitled

a guest
Aug 16th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. try {
  2. Class.forName("org.postgresql.Driver");
  3. con = DriverManager.getConnection("jdbc:postgresql://" + host + ":" + port + "/" + database + "?autoReconnect=true", username, password);
  4. } catch (ClassNotFoundException e) {
  5. System.out.println("Driver not found!");
  6. } catch (Exception e) {
  7. e.printStackTrace();
  8. System.err.println(e.getClass().getName()+": "+e.getMessage());
  9. }
  10. System.out.println("Connected to database");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement