public List<Order> getAllOrdersByCustomerId(int customerId) throws SQLException {
List<Order> AllOrdersByCustomerId = new ArrayList<>();
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
String sqlQuery = "SELECT * FROM dbo.Orders WHERE customer_id = ?";
con = JDBCConnection.getConnection();
pstmt = con.prepareStatement(sqlQuery);
pstmt.setInt(1, customerId);
pstmt.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (con != null) {
JDBCConnection.closeConnection(con);
}
if (rs != null) {
JDBCConnection.closeResultSet(rs);
}
}
return AllOrdersByCustomerId;
}
//Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because "lo" is null