Esempio n. 1
0
  @Override
  public boolean delete(BeanEstante id) {
    String query = "DELETE FROM Estante where id_estante= ?;";

    try {
      PreparedStatement ps = con.prepareStatement(query);
      ps.setInt(1, id.getId_estante());

      if (ps.executeUpdate() == 1) {
        ps.close();
        return true;
      }
      ps.close();
    } catch (SQLException ex) {
      Logger.getLogger(DaoEstante.class.getName()).log(Level.SEVERE, null, ex);
    }

    return false;
  }
Esempio n. 2
0
  @Override
  public boolean update(BeanEstante bean) {
    String query = "UPDATE Estante SET ubicacion =? where id_estante=?;";

    try {
      PreparedStatement ps = con.prepareStatement(query);
      ps.setString(1, bean.getUbicacion());
      ps.setInt(2, bean.getId_estante());

      if (ps.executeUpdate() == 1) {
        ps.close();
        return true;
      }
      ps.close();
    } catch (SQLException ex) {
      Logger.getLogger(DaoEstante.class.getName()).log(Level.SEVERE, null, ex);
    }

    return false;
  }