This code works completely fine:
try {
sql = "SELECT * from profiles";
ResultSet res = stmt.executeQuery(sql);
while(res.next()) {
Profiles pProfile = new Profiles();
pProfile.setPersonalnummer(res.getInt(1));
pProfile.setAnwesenheit(res.getBoolean(2));
pProfile.setGrundDerAbwesenheit(res.getString(3));
pProfile.setRolle(res.getString(4));
pProfile.setWerk(res.getString(5));
pProfile.setMandant(res.getString(6));
pProfile.setFileName(res.getString(7));
allProfiles.add(pProfile);
}
} catch (SQLException e) {
e.printStackTrace();
}
return allProfiles;
Somehow this doesn't work:
public List<Projects> getAllProjects() {
try {
sql = "SELECT * from projects";
ResultSet res = stmt.executeQuery(sql);
while(res.next()) {
Projects pProject = new Projects();
pProject.setProjektname(res.getString(1));
pProject.setProjektid(res.getInt(2));
allProjects.add(pProject);
}
} catch (SQLException e) {
e.printStackTrace();
}
return allProjects;
}
I just copy-pasted it, changed the values, but somehow i get a "500 - Internal Server Error" when using the "getAllProjects()" method. The error message says that there is a Null Pointer Exception when executing "allProjects.add(pProject)". Maybe somebody can help me? Thanks in advance!