Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ConnectionFactory {
- private String url = "jdbc:postgresql://localhost:5432/aluno";
- private String user = "postgres";
- private String password = "";
- public Connection getConnection(){
- try{
- Class.forName("org.postgresql.Driver");
- return DriverManager.getConnection(url, user, password);
- } catch (SQLException | ClassNotFoundException e){
- throw new RuntimeException(e);
- return DriverManager.getConnection(url, user, password);
- public AlunoDAO(){
- if(connection == null){
- connection = new ConnectionFactory().getConnection();
- }
- }
- connection.getConnection()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement