Exemplo n.º 1
0
  public List<EstacionParadero> findAllEstacionParadero() {
    String sql_query =
        " SELECT id, ubicacion, estado from estacion_paradero JOIN"
            + " estacion ON estacion_paradero.id_estacion = estacion.id WHERE estado=true";

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

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

      while (table.next()) {
        EstacionParadero estacion = new EstacionParadero();
        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;
  }
Exemplo n.º 2
0
  public List<EstacionParadero> findEstacionParaderoActivas(String ubicacion) {
    String ubicacion_sql = "";
    if (!ubicacion.equals("")) ubicacion_sql = " and ubicacion like '%" + ubicacion + "%'";
    String sql_query =
        "SELECT id, ubicacion, estado FROM estacion_paradero JOIN"
            + " estacion ON estacion_paradero.id_estacion= estacion.id"
            + " WHERE estado=true "
            + ubicacion_sql;

    List<EstacionParadero> estaciones = new ArrayList<EstacionParadero>();
    try {
      Connection conn = fachada.conectar();
      Statement sequence = conn.createStatement();
      ResultSet table = sequence.executeQuery(sql_query);

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

    } catch (SQLException se) {
      se.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return estaciones;
  }