Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1.      public ArrayList<Wypożyczenie> generateWypozyczeniaList()
  2.        {
  3.            wypozyczenia = new ArrayList<Wypożyczenie>();
  4.            
  5.             try {
  6.                 String sql = "SELECT * FROM wypożyczenie";
  7.                 ResultSet rs = null;
  8.                 PreparedStatement st = (PreparedStatement) Connect.connection.prepareStatement(sql);
  9.                 rs = st.executeQuery();
  10.                
  11.                 Wypożyczenie wypozyczenie;
  12.                          while (rs.next())
  13.                              {
  14.                              wypozyczenie = new Wypożyczenie();
  15.                              wypozyczenie.setID(rs.getInt("ID"));
  16.                              wypozyczenie.setData_wypożyczenia(rs.getDate("Data_wypożyczenia"));
  17.                              wypozyczenie.setGodzina_wypożyczenia(rs.getTime("Godzina__wypożyczenia"));
  18.                              wypozyczenie.setData_zwrotu(rs.getDate("Data_zwrotu"));
  19.                              wypozyczenie.setGodzina_zwrotu(rs.getTime("Godzina_zwrotu"));
  20.                              wypozyczenie.setStatus(rs.getInt("Status"));
  21.                              wypozyczenie.setKlientid(rs.getInt("KlientID"));
  22.                              wypozyczenie.setSamochódid(rs.getInt("SamochódID"));
  23.                              wypozyczenie.setUżytkownikid(rs.getInt("UżytkownikID"));
  24.                              wypozyczenia.add(wypozyczenie);
  25.                              }
  26.             } catch (Exception e) {
  27.                 e.printStackTrace();
  28.                 System.err.println("Got an exception!(getWypozyczeniaList) ");
  29.                 System.err.println(e.getMessage());
  30.                 return null;
  31.             }
  32.                return wypozyczenia;
  33.        }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement