Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Conexion{
- private String bdd="prueba";
- private String usuario="root";
- private String clave="clave";
- public static Connection con;
- private Statement stmt;
- public Conexion()
- {
- try{
- DriverManager.registerDriver(new org.gjt.mm.mysql.Driver());
- con=DriverManager.getConnection("jdbc:mysql://localhost/"+bdd,usuario,clave);
- }catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- public void Insertar(String sql){
- try{
- stmt=con.createStatement();
- stmt.executeUpdate(sql);
- stmt.close();
- con.close();
- }catch(SQLException e){
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement