package org.mig.java.DAO;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.sql.DataSource;
import org.mig.java.Exceptions.DAOException;
import org.mig.java.Interfaces.IPedidos;
import org.mig.java.Interfaces.IProductos;
import org.mig.java.Interfaces.IRegistro;
import org.mig.java.Interfaces.ITiendas;
import org.mig.java.Interfaces.IUsuario;

public abstract class DAOFactory {

    // Constants ----------------------------------------------------------------------------------
    //PARA EL DEPLOY CAMBIAR EL LOCALHOST POR 46.105.17.142
    //PASSWORD DEPLOY : hildegard / P@ssw0rd3343 
    private static final String URL = "jdbc:mysql://46.105.17.142:3306/proyectofinaldaw";
    private static final String DRIVER = "com.mysql.jdbc.Driver";
    private static final String USERNAME = "hildegard";
    private static final String PASSWORD = "P@ssw0rd3343";

    // Actions ------------------------------------------------------------------------------------
    /**
     * Returns a new DAOFactory instance for the given database name.
     *
     * @return A new DAOFactory instance for the given database name.
     */
    public static DAOFactory getInstance() {

        String url = URL;
        String driverClassName = DRIVER;
        String password = PASSWORD;
        String username = USERNAME;
        DAOFactory instance;

        try {
            Class.forName(driverClassName);
        } catch (ClassNotFoundException e) {
            throw new DAOException(
                    "El driver '" + driverClassName + "' no se encuentra en la ruta especificada.");
        }
        instance = new DriverManagerDAOFactory(url, username, password);

        return instance;
    }

    /**
     * Returns a connection to the database. Package private so that it can be
     * used inside the DAO package only.
     *
     * @return A connection to the database.
     * @throws SQLException If acquiring the connection fails.
     */
    abstract Connection getConnection() throws SQLException;

    // DAO implementation getters -----------------------------------------------------------------
    /**
     * Returns the User DAO associated with the current DAOFactory.
     *
     * @return The User DAO associated with the current DAOFactory.
     */
    public IUsuario getUsuarioDAO() {
        return new DAOUsuario(this);
    }

    public ITiendas getTiendasDAO() {
        return new DAOTiendas(this);
    }

    public IProductos getProductosDAO() {
        return new DAOProductos(this);
    }

    public IPedidos getPedidosDAO() {
        return new DAOPedidos(this);
    }

    public IRegistro getRegistroDAO() {
        return new DAORegistro(this);
    }

    // You can add more DAO implementation getters here.
}

// Default DAOFactory implementations -------------------------------------------------------------
/**
 * The DriverManager based DAOFactory.
 */
class DriverManagerDAOFactory extends DAOFactory {

    private final String url;
    private final String username;
    private final String password;

    DriverManagerDAOFactory(String url, String username, String password) {
        this.url = url;
        this.username = username;
        this.password = password;
    }

    @Override
    Connection getConnection() throws SQLException {
        return DriverManager.getConnection(url, username, password);
    }
}

/**
 * The DataSource based DAOFactory.
 */
class DataSourceDAOFactory extends DAOFactory {

    private final DataSource dataSource;

    DataSourceDAOFactory(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    @Override
    Connection getConnection() throws SQLException {
        return dataSource.getConnection();
    }
}

/**
 * The DataSource-with-Login based DAOFactory.
 */
class DataSourceWithLoginDAOFactory extends DAOFactory {

    private final DataSource dataSource;
    private final String username;
    private final String password;

    DataSourceWithLoginDAOFactory(DataSource dataSource, String username, String password) {
        this.dataSource = dataSource;
        this.username = username;
        this.password = password;
    }

    @Override
    Connection getConnection() throws SQLException {
        return dataSource.getConnection(username, password);

    }
}

@@ -645,26 +645,20 @@
 ard / P@
-ssw0rd3
+12
 34
-3
  %0D%0A    p
@@ -915,20 +915,13 @@
  = %22
-P@ssw0rd3343
+12342
 %22;%0D%0A

Update DAOFactory.java