6
I have this method in Java, which queries in the database and returns me a list of students.
The method is searching in the BD, but does not return the data correctly...
public static List<alunos> teste() throws SQLException {
String sql = "Select * from alunos";
Statement stm = Conectar.Mysql(ip(), banco(), usuario(), senha(), sql);
ResultSet rs = stm.executeQuery(sql);
List<alunos> valores = new ArrayList<>();
while (rs.next()) {
alunos objeto = new alunos();
objeto.setNome(rs.getString("nome"));
objeto.setMatricula(rs.getString("matricula"));
objeto.setCurso(rs.getString("curso"));
valores.add(objeto);
}
return valores;
}
He returns to me [teste.alunos@e26948, teste.alunos@1baeedf, teste.alunos@3f4d3d, teste.alunos@13b32d7]
Why not make a loop to display each Arraylist item?
– user28595