JDBC how to get all records in a single object?
let's say I'm taking all I need from the database like this (query is a variable with the SQL query)
ResultSet rs = st.executeQuery(query);
but to build up every time here's a design I don't want
while (rs.next()) {
System.out.println(rs.getString("id"));
System.out.println(rs.getString("name"));
}
because you never know how many times I need them.
you can pick them up for example in the form of the array of objects, or in any other more s-cook form ?
PS if not, please fikalii not to throw, because with java-oops just getting started