Advertisement
Guest User

Untitled

a guest
Jun 11th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. public class DBConnection {
  2.  
  3. static Connection connection;
  4. static org.postgresql.jdbc2.optional.ConnectionPool connectionPool = new ConnectionPool();
  5.  
  6. public DBConnection() throws SQLException {
  7.  
  8. System.out.println("-------- PostgreSQL "
  9. + "JDBC Connection Testing ------------");
  10.  
  11. try {
  12.  
  13. Class.forName("org.postgresql.Driver");
  14.  
  15. } catch (ClassNotFoundException e) {
  16.  
  17. System.out.println("Where is your PostgreSQL JDBC Driver? "
  18. + "Include in your library path!");
  19. e.printStackTrace();
  20. return;
  21.  
  22. }
  23.  
  24. System.out.println("PostgreSQL JDBC Driver Registered!");
  25.  
  26.  
  27. connectionPool.setUser("postgres");
  28. connectionPool.setPassword("toor");
  29. connectionPool.setUrl("jdbc:postgresql://127.0.0.1:5432/bank_database");
  30. connectionPool.setSspiServiceClass("org.postgresql.Driver");
  31.  
  32. connection = DriverManager.getConnection(
  33. "jdbc:postgresql://127.0.0.1:5432/bank_database", "postgres",
  34. "toor");
  35. System.out.println(connectionPool.getConnection().toString());
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement