public static Seller get(int id) { Seller seller = new Seller(); String query = "Select * from Sellers where id=" + id; try { ResultSet result = statement.executeQuery(query); if (result.next()) { seller.setId(result.getInt(1)); seller.setName(result.getString(2)); seller.setSurname(result.getString(3)); seller.setPassword(result.getString(4)); } } catch (SQLException e) { return null; } return seller; }
public static List<Seller> getAll() { List<Seller> list = new ArrayList<Seller>(); String query = "Select * from Sellers"; try { ResultSet result = statement.executeQuery(query); while (result.next()) { Seller seller = new Seller(); seller.setId(result.getInt(1)); seller.setName(result.getString(2)); seller.setSurname(result.getString(3)); seller.setPassword(result.getString(4)); list.add(seller); } } catch (SQLException e) { } return list; }