package Persistencia;
import java.sql.DriverManager;
import java.sql.SQLException;
import com.mysql.jdbc.Connection;
public class Agente {
protected static Agente mInstancia = null;
protected Connection mBD;
protected String driver = "com.mysql.jdbc.Driver";
protected String usuario = "root";
protected String contraseña = "";
protected String url="jdbc:mysql://localhost/Persona/";
protected Agente() throws SQLException, ClassNotFoundException {
Class.forName(driver);
mBD = (Connection) DriverManager.getConnection(url, usuario, contraseña);
}
public static Agente getAgente() throws SQLException, ClassNotFoundException {
if (mInstancia == null)
mInstancia = new Agente();
return mInstancia;
}
public Connection getBD() throws SQLException {
if(mBD.isClosed())
mBD = (Connection) DriverManager.getConnection(url, usuario, contraseña);
return mBD;
}
}