-1
我已经花了一整天找这一点,据我检查我总是一个空的ArrayList坚持。我也尝试显示我找到的第一个记录,并且我得到了空值。应该插入到ArrayList中的只有课程,所以Strings。插入到的resultSet ArrayList中
public String getProfessorCourses(){
................
//get the id related of the name
String s = null;
String sqlQuery = "SELECT courses.title FROM courses INNER JOIN professors_courses ON professors_courses.course_id = course.course_id WHERE prof_id = '"+1+"'";
ArrayList<String> result = new ArrayList<String>();
try {
rst = stmt.executeQuery(sqlQuery);
} catch (SQLException e1) {
e1.printStackTrace();
}
try {
//titles are not inserted
while(rst.next()){
//s = new String(rst.getString(1));
//s = rst.getString(1);
s = new String(rst.getString("title"));
}
} catch (SQLException e) {
e.printStackTrace();
}
.........................
return s;
}