I have difficult storing multiple result sets into an ArrayList. Also I need to display them in a JTextArea. But the problem is, I can't get it to display anything.
public static ArrayList<Wall> getWallPosts(int postId){
ArrayList<Wall> postList = new ArrayList<Wall>();
ResultSet rs = null;
DBController db = new DBController();
db.setUp("myDatabase");
String dbQuery = "SELECT Id FROM Wall WHERE ID ="+postId;
rs = db.readRequest(dbQuery);
try{
while (rs.next()){
int wallId = rs.getInt("Id");
String wallPoster = rs.getString("Poster");
String wallPost = rs.getString("Post");
String wallDate = rs.getString("Tdate");
Wall w1 = new Wall(wallPoster, wallPost , wallDate);
postList.add(w1);
}
}
catch (Exception e) {
e.printStackTrace();
}
db.terminate();
return postList;
}
//The method for displaying the result sets
public void retrieveCategoryQuestionList() {
//get the list and store in array
ArrayList<Wall> aList = Wall.getWallPosts(id);
for(id = 1; id<aList.size();id++)
jTextAreaWall.append(w2.getPost());
}
The fields in the database is Id, Poster, Post, Tdate