Guest User

Untitled

a guest
Jul 10th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5.  
  6. package com.application.Database;
  7.  
  8. /**
  9. * Classe para realizar conexoes usando JDBC postgresql
  10. * @author aluno
  11. */
  12. public class PostgresqlConnection extends DatabaseConnection {
  13.  
  14. public PostgresqlConnection(String username, String password, String dbName, String host, int port) {
  15. setUsername(username);
  16. setPassword(password);
  17. setDbName(dbName);
  18. setHost(host);
  19. setPort(port);
  20. setDriver("org.postgresql.Driver");
  21. setUri(buildUri());
  22. }
  23.  
  24. public PostgresqlConnection(String username, String password, String dbName, String host) {
  25. setUsername(username);
  26. setPassword(password);
  27. setDbName(dbName);
  28. setHost(host);
  29. setPort(5432);
  30. setDriver("org.postgresql.Driver");
  31. setUri(buildUri());
  32. }
  33.  
  34. /**
  35. * Método privado que constrói a URI para conexao
  36. * @return String String padrao de conexao com PostgreSQL
  37. */
  38. private String buildUri() {
  39. return "jdbc:postgresql://"+getHost()+":"+getPort()+"/"+getDbName();
  40. }
  41.  
  42. }
Add Comment
Please, Sign In to add comment