-1
저는 이것을 찾기 위해 하루 종일 보냈습니다. 그리고 나는 항상 빈 ArrayList를 고수했습니다. 나는 또한 내가 찾은 첫 번째 레코드 만 표시하려고했는데 null이 있습니다. 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;
}