I have this method in Java, which queries the database and returns me a list of students.
The method is querying the DB 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;
}
It returns me [teste.alunos@e26948, teste.alunos@1baeedf, teste.alunos@3f4d3d, teste.alunos@13b32d7]