예제 #1
0
  @Override
  List<BeanEstante> passResultSet(ResultSet res, List<BeanEstante> list) throws SQLException {
    while (res.next()) {
      BeanEstante bean = new BeanEstante();

      bean.setId_estante(res.getInt("id_estante"));
      bean.setUbicacion(res.getString("ubicacion"));
      list.add(bean);
    }
    return list;
  }
예제 #2
0
  @Override
  public BeanEstante get(int id) {
    BeanEstante bean = new BeanEstante();

    String quuery = "SELECT * FROM Estante WHERE id_estante= ?;";

    try {
      PreparedStatement ps = con.prepareStatement(quuery);
      ps.setInt(1, id);
      ResultSet result = ps.executeQuery();
      if (result.next()) {
        bean.setId_estante(result.getInt("id_estante"));
        bean.setUbicacion(result.getString("ubicacion"));
      }

      ps.close();

    } catch (SQLException ex) {
      Logger.getLogger(DaoEstante.class.getName()).log(Level.SEVERE, null, ex);
    }

    return bean;
  }
예제 #3
0
  public BeanEstante findByNombre(String nombre) {

    String query = "SELECT * from Estante where ubicacion= ?;";
    BeanEstante ed = new BeanEstante();

    try {
      PreparedStatement ps = con.prepareStatement(query);
      ps.setString(1, nombre);

      ResultSet result = ps.executeQuery();
      if (result.next()) {

        ed.setId_estante(result.getInt("id_estante"));

        ed.setUbicacion(result.getString("ubicacion"));
      }

    } catch (SQLException ex) {
      Logger.getLogger(DaoAutor.class.getName()).log(Level.SEVERE, null, ex);
    }

    return ed;
  }