public static ArrayList<postInfo> getPosts(long offering_id, boolean privilegeFlag){
        try{
            PreparedStatement pstmt;
            if (!privilegeFlag){
                pstmt = conn.prepareStatement("select S.post_id, S.parent_post_id, S.student_id, student.name, S.mytime, "
                        + "(select max(mytime) from post as T where T.parent_post_id = S.post_id) as maxTime, S.content "
                        + "from post as S natural join student "
                        + "where offering_id = ? and post_id = parent_post_id "
                        + "order by maxTime desc");
            }
            else{
                pstmt = conn.prepareStatement("select S.post_id, S.parent_post_id, S.student_id, student.name, S.mytime, "
                        + "(select max(mytime) from post as T where T.parent_post_id = S.post_id) as maxTime, S.content "
                        + "from post as S natural join student "
                        + "where offering_id = ? and post_id = parent_post_id and privilege_flag = ? "
                        + "order by maxTime desc");
                pstmt.setBoolean(2, privilegeFlag);
            }
            pstmt.setLong(1, offering_id);

            ResultSet rset = pstmt.executeQuery();
            
            ArrayList<postInfo> primaryPostList = new ArrayList<postInfo>();
            
            while(rset.next()){
                postInfo newPost = new postInfo();
                newPost.postId = rset.getLong("post_id");
                newPost.parentPostId = rset.getLong("parent_post_id");
                newPost.studentName = rset.getString("student.name");
                newPost.studentId = rset.getString("student_id");
                newPost.mytime = rset.getString("myTime");
                newPost.content = rset.getString("content");
                
                primaryPostList.add(newPost);
            }
            
            ArrayList<postInfo> postList = new ArrayList<postInfo>();
            
            for (int i = 0; i < primaryPostList.size(); i++){
                postList.add(primaryPostList.get(i));
                
                pstmt = conn.prepareStatement("select post_id, parent_post_id, student_id, student.name, mytime, content "
                        + "from post natural join student "
                        + "where post_id != ? and parent_post_id = ? "
                        + "order by mytime asc");
                pstmt.setLong(1, primaryPostList.get(i).postId);
                pstmt.setLong(2, primaryPostList.get(i).postId);
                
                int numCommentsReqd = 3;
                
                rset = pstmt.executeQuery();
                rset.afterLast();
                ArrayList<postInfo> tempCommentList = new ArrayList<postInfo>();
                
                while(rset.previous() && numCommentsReqd > 0){
                    numCommentsReqd--;
                    postInfo newPost = new postInfo();
                    newPost.postId = rset.getLong("post_id");
                    newPost.parentPostId = rset.getLong("parent_post_id");
                    newPost.studentName = rset.getString("student.name");
                    newPost.studentId = rset.getString("student_id");
                    newPost.mytime = rset.getString("myTime");
                    newPost.content = rset.getString("content");
                    
                    tempCommentList.add(newPost);
                }
                
                for (int j = tempCommentList.size() - 1; j >= 0; j--){
                    postList.add(tempCommentList.get(j));
                }
            }

            return postList;
            
        } catch (SQLException sqle) {
            System.out.println("SQLException : " + sqle);
            return null;
        }                
    }