Пример #1
0
 public Map retrieve(int id, GregorianCalendar gc) throws SQLException {
   FConnect con = new FConnect();
   String[] cond = {Integer.toString(id), Utility.getStringFromDate(gc)};
   String[] keys = {"id", "decollo"};
   ResultSet rs = con.search(table, keys, cond);
   Map<String, Object> map = new HashMap<>();
   while (rs.next()) {
     map = new HashMap<>();
     Route r = new Route();
     r.createFromDB(getRouteID(id));
     map.put("route", r);
     map.put("ID", Integer.toString(rs.getInt(1)));
     map.put("date", Utility.getDateFromString(rs.getString(2)));
     map.put("seats", rs.getInt(4));
   }
   con.close();
   return map;
 }
Пример #2
0
 public static ArrayList getFlightsRouteDate(int id, String dat) throws SQLException {
   FConnect con = new FConnect();
   String ids = Integer.toString(id);
   String[] cond = {ids, dat};
   String[] keys = {"idtratta", "decollo"};
   ResultSet rs = con.search(table, keys, cond);
   ArrayList list = new ArrayList();
   HashMap<String, Object> map;
   while (rs.next()) {
     map = new HashMap<>();
     map.put("ID", Integer.toString(rs.getInt(1)));
     map.put("date", rs.getString(2));
     map.put("seats", rs.getInt(4));
     list.add(map);
   }
   // System.out.println(list.size());
   if (list.isEmpty()) {
     con.close();
     throw new SQLException("Nessun risultato trovato per la tratta richiesta");
   }
   con.close();
   return list;
 }