Example #1
0
 public static int getRouteID(int id) throws SQLException {
   FConnect con = new FConnect();
   ResultSet rs = con.load("volo", "id = " + id);
   // System.out.println(rs.getRow());
   int rt = 0;
   while (rs.next()) rt = rs.getInt(3);
   con.close();
   return rt;
 }
Example #2
0
 public void store() throws SQLException {
   FConnect con = new FConnect();
   ArrayList<String> values = new ArrayList<>();
   values.add("DEFAULT");
   values.add(this.getDateString());
   values.add(Integer.toString(this.route.getIdFromDB()));
   values.add(Integer.toString(this.seats));
   con.store(table, values);
   con.close();
 }
Example #3
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;
 }
Example #4
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;
 }