www.lauttrui.com
java read data to arraylist from databasepublic static ArrayList<Stuff> getAllStuff() throws ClassNotFoundException, SQLException {
String sql = "Select * From Stuff";
Statement stm;
ResultSet rst;
Connection conn=DBConnection.getDBConnection().getConnection();
stm = conn.createStatement();
rst = stm.executeQuery(sql);
ArrayList<Stuff> arrList = new ArrayList<>();
while (rst.next()) {
Stuff stuff = new Stuff(rst.getString("id"), rst.getString("name"), rst.getString("address"), rst.getDouble("salary"));
arrList.add(stuff);
}
return arrList;
}