Advertisement
Guest User

Untitled

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