Example #1
0
  public List<Estacion> findAllEstacion() {
    String sql_query = " SELECT id, ubicacion, estado FROM estacion";

    List<Estacion> estaciones = new ArrayList<Estacion>();

    try {
      Connection conn = fachada.conectar();
      Statement sequence = conn.createStatement();
      ResultSet table = sequence.executeQuery(sql_query);

      while (table.next()) {
        Estacion estacion = new Estacion();
        estacion.setId(table.getInt("id"));
        estacion.setUbicacion(table.getString("ubicacion"));
        estacion.setEstado(table.getBoolean("estado"));

        estaciones.add(estacion);
      }

      fachada.cerrarConexion(conn);
    } catch (SQLException se) {
      se.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return estaciones;
  }
Example #2
0
  public Estacion findEstacion(Integer id) {
    String sql_query = "SELECT id, ubicacion, estado FROM estacion WHERE id=" + id;

    Estacion estacion = new Estacion();

    try {
      Connection conn = fachada.conectar();
      Statement sequence = conn.createStatement();
      ResultSet table = sequence.executeQuery(sql_query);

      while (table.next()) {
        estacion.setId(table.getInt("id"));
        estacion.setUbicacion(table.getString("ubicacion"));
        estacion.setEstado(table.getBoolean("estado"));
      }
    } catch (SQLException se) {
      se.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return estacion;
  }