Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. public class ConnectionFactory {
  2.  
  3. private String url = "jdbc:postgresql://localhost:5432/aluno";
  4. private String user = "postgres";
  5. private String password = "";
  6.  
  7. public Connection getConnection(){
  8. try{
  9. Class.forName("org.postgresql.Driver");
  10. return DriverManager.getConnection(url, user, password);
  11. } catch (SQLException | ClassNotFoundException e){
  12. throw new RuntimeException(e);
  13.  
  14. return DriverManager.getConnection(url, user, password);
  15.  
  16. public AlunoDAO(){
  17. if(connection == null){
  18. connection = new ConnectionFactory().getConnection();
  19. }
  20. }
  21.  
  22. connection.getConnection()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement