Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/04/2016, 19:52
Avatar de chosbuster
chosbuster
 
Fecha de Ingreso: marzo-2016
Mensajes: 10
Antigüedad: 8 años, 1 mes
Puntos: 0
borrar filas de un jtable y del la BBDD

buenas,consigo k se borre la fila de la tabla (desaparece momentaneamente, al volver a cargar la BBDD vuelve otra vez) pero no de la base de datos. si alguien me puede ayudar se lo agradeceria ;)


Código:
private void BtoEliminarClientesActionPerformed(java.awt.event.ActionEvent evt) {                                                    

        int fila = TblTablaClientesRegistrados.getSelectedRow();
        System.out.println(fila);
        if (fila >= 0) {
            acciones.getTablaListaClientes().removeRow(fila);
        } else {
            JOptionPane.showMessageDialog(null, "Seleccione algun cliente.");
        }
        int ID = (fila);
        System.out.println(fila);
        Conexion mysql = new Conexion();
        Connection cn = mysql.conectar();
        String sSql = "DELETE FROM fastfoodcompany WHERE ID = ?";
        
        
        try {
            PreparedStatement pst = cn.prepareStatement(sSql);
            pst.setInt(1, ID);
            pst.execute();
            
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, ex);
        }