Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. package hotelchain.database.conn;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. public class PostGresConnUtils {
  8.  
  9. public static Connection getPostGresConnection()
  10. throws ClassNotFoundException, SQLException {
  11.  
  12. // Note: Change the connection parameters accordingly.
  13. String hostName = "web0.site.uottawa.ca";
  14. String port = "15432";
  15. String userName = "whu061";
  16. String password = "XXXXX";
  17.  
  18. return getPostGresConnection(hostName, port, userName, password);
  19. }
  20.  
  21. public static Connection getPostGresConnection(String hostName, String port,
  22. String userName, String password) throws ClassNotFoundException,
  23. SQLException {
  24.  
  25. Class.forName("org.postgresql.Driver");
  26.  
  27. // URL Connection for Postgresql
  28. //jdbc:postgresql://web0.site.uottawa.ca:15432/svale054
  29. String connectionURL = "jdbc:postgresql://" + hostName + ":" + port + "/" + userName;
  30.  
  31. Connection conn = DriverManager.getConnection(connectionURL, userName,
  32. password);
  33. return conn;
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement