Guest User

Untitled

a guest
May 9th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3.  
  4. public class PostgreSQLJDBC {
  5. public static void main(String args[]) {
  6. Connection c = null;
  7. try {
  8. Class.forName("org.postgresql.Driver");
  9. c = DriverManager
  10. .getConnection("jdbc:postgresql://localhost:5432/testdb",
  11. "postgres", "123");
  12. } catch (Exception e) {
  13. e.printStackTrace();
  14. System.err.println(e.getClass().getName()+": "+e.getMessage());
  15. System.exit(0);
  16. }
  17. System.out.println("Opened database successfully");
  18. }
  19. }
Add Comment
Please, Sign In to add comment