You are on page 1of 1

/*

* To change this template, choose Tools | Templates


* and open the template in the editor.
*/
package base_datos;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Connection;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Conexion {
private Connection con;
public void cargardriver(){
try {
Class.forName("org.apache.derby.jdbc.ClientDriver");
} catch (ClassNotFoundException ex) {
System.out.println("No se pudo cargar el Driver");
ex.printStackTrace();
}
}
public Connection obtenerconexion(){
try {
con=DriverManager.getConnection("jdbc:derby://localhost:1527/MiBaseD
atos");
} catch (SQLException ex) {
System.out.println("No se pudo obtener el Driver");
ex.printStackTrace();
}
return con;
}
public void cerrarconexion(){
try {
con.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}

You might also like