Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Persistencia() {
- base = BaseDatos.getInstancia();
- base.conectar("jdbc:mysql://localhost/dda", "root", "1234");
- }
- public void conectar(String url,String u,String p){
- try {
- conexion = DriverManager.getConnection(url, u, p);
- stmt = conexion.createStatement();
- } catch (SQLException ex) {
- System.out.println("Error al conectar:" + ex.getMessage());
- }
- }
- public Connection conexion() {
- if (conexion == null) {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- conexion= DriverManager.getConnection("jdbc:mysql://"+host+"/"+bd, usuario, contrasena);
- System.out.println("exito");
- } catch (ClassNotFoundException | SQLException ex) {
- Logger.getLogger(conexionBD.class.getName()).log(Level.SEVERE, null, ex);
- System.out.println("error");
- }
- }
- return conexion;
- }
Add Comment
Please, Sign In to add comment