@Override public boolean add(Object o) { Caracteristica catacteristica = (Caracteristica) o; try { PreparedStatement query = connection.prepareStatement( "insert into Caracteristica (marca, modelo, numSerie, costo, moneda) values (?,?,?,?,?)"); query.setString(1, catacteristica.getMarca()); query.setString(2, catacteristica.getModelo()); query.setString(3, catacteristica.getNumSerie()); query.setDouble(4, catacteristica.getCosto()); query.setString(5, catacteristica.getMoneda()); query.execute(); query.close(); return true; } catch (Exception ex) { System.err.println(ex); return false; } }
@Override public boolean edit(Object o) { Caracteristica catacteristica = (Caracteristica) o; try { PreparedStatement query = connection.prepareStatement( "update Caracteristica set marca=?, modelo=?, numSerie=?, costo=?, moneda=? where idCaracteristica=?"); query.setString(1, catacteristica.getMarca()); query.setString(2, catacteristica.getModelo()); query.setString(3, catacteristica.getNumSerie()); query.setDouble(4, catacteristica.getCosto()); query.setString(5, catacteristica.getMoneda()); query.setInt(6, catacteristica.getIdCaracteristica()); query.execute(); query.close(); return true; } catch (Exception ex) { System.err.println(ex); return false; } }