Ejemplo n.º 1
0
  // DELETE MOVIE FROM DATABASE AND TABLEMODEL
  public void deleteMovie(int row) {
    int id = (Integer) tabModel.getValueAt(row, Movie.COL_ID);
    String myDel = "";
    try {
      if (cargaControlador() > -1) {
        if (open("jdbc:mysql://" + host + ":" + port + "/" + database, user, pass) > -1) {

          myDel = "delete from movies where id=\"" + id + "\"";
          if (delete(myDel) > -1) {
            // System.out.println("Deleting succesful!!!");
            tabModel.deleteMovie(row);
          } else {
            Errors.showError(Errors.DB_DELETE);
            Errors.writeError(Errors.DB_DELETE, myDel + "\n");
          }
          close();
        }
      }
    } catch (Exception ex) {
      Errors.showError(Errors.DB_DELETE);
      Errors.writeError(Errors.DB_DELETE, myDel + "\n");
    }
  }