I have a database with movies and I have movie as a class. I am tring to get the movies from the database loaded into my GUI, but i cannot seem to get them into my arraylist. I get a null exception and I don't see where I'm going wrong.
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;
}
This is output from the stacktrace run:
List of Movies: 
Exception: null
null
BUILD SUCCESSFUL (total time: 0 seconds)
public static void main(String[] args) {
    controller.getMovies(movieList);
}
 
    