/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package demojsoncrud.sqlserverdao;

import demojsoncrud.dao.DAOFactory;
import demojsoncrud.dao.PersonaDAO;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author Alonso
 */
public class SqlserverDAOFactory extends DAOFactory {

    public static Connection obtenerConexion(String base) {
        Connection connection = null;
        if (base.equalsIgnoreCase("demojsoncrud")) {
            String user = "sa";
            String pwd = "Saco1357$";
            String url = "jdbc:sqlserver://localhost:1433;databaseName=demojsoncrud";
            String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
            try {
                Class.forName(driver);
                connection = DriverManager.getConnection(url, user, pwd);
            } catch (ClassNotFoundException | SQLException e) {
                System.out.println("Error al conectarse => " + e.getMessage());
            }
        }

        return connection;
    }

//    public static void main(String[] args) {
//        SqlserverDAOFactory sqlserverDAOFactory = new SqlserverDAOFactory();
//        System.out.println(sqlserverDAOFactory.obtenerConexion("demojsoncrud"));
//    }
    @Override
    public PersonaDAO getPersonaDAO() {
        return new PersonaSqlserverDAO();
    }
}
