我有一个电影数据库,我把电影作为一个班级。我想把数据库中的电影加载到我的GUI中,但我似乎无法将它们带入我的arraylist。我得到一个空例外,我不知道我哪里出错了。
public ArrayList getMovies(ArrayList movieList2)
{
movieList = movieList2;
Connection con = null;
try {
con = DriverManager.getConnection(
databaseURL, user, password);
Statement sta = con.createStatement();
ResultSet res = sta.executeQuery(
"SELECT * FROM MOVIES");
System.out.println("List of Movies: ");
while (res.next()) {
Movie movie = new Movie();
movie.setTitle(res.getString((String)"Title"));
movie.setYear(res.getInt("Yearmade"));
movie.setGenre(res.getString("Genre"));
movie.setDuration(res.getInt("Duration"));
movie.setActors(res.getString("Actor"));
movie.setDirector(res.getString("Director"));
movieList2.add(movie);
System.out.println(movie);
}
res.close();
sta.close();
con.close();
} catch (Exception e) {
System.err.println("Exception: " + e.getMessage());
}
System.out.println(movieList2);
return movieList2;
}
这是stacktrace的输出 运行:
List of Movies:
Exception: null
null
BUILD SUCCESSFUL (total time: 0 seconds)
public static void main(String[] args) {
controller.getMovies(movieList);
}
答案 0 :(得分:1)
if(jQuery('#role').val() == 'seeking-to-acquire-a-business') {
jQuery("#ze-next").attr('value', 'Register');
} else {
jQuery("#ze-next").attr('value', 'Next');
}