Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using ResultSet

 
Patrick Mugabe
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I am using ResultSet to slect data from my database and displaying it on a textArea. The problem is that, it's only displaying one row only so I don't know how I can make it display all the rows.
The section of code that is retrieving the data is:
try{
rs2 = stat.executeQuery(select2);
while(rs2.next())
{
stat = con.createStatement();
String field2 = rs2.getString(2);
int field3 = rs2.getInt(3);
String field5 = rs2.getString(5);
String field7 = rs2.getString(7);
String field8 = rs2.getString(8);

String colName = "Work in Progress Details:\nThe following data represents: \n" +
"EmpName, " + " FaultID, " + " Category, " + " Progress " + " and Solution";
String test = field2 + " " + field3 + " " + field5 + " " + field7 +
" " + field8 + " " ;//+ field9;
txtReport.setText(colName + "\n\n" + test);
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
YOu are using the wrong method on your TextArea. You need to use txtReport.append(String s) instead of .setText(String s). When you use setText(), it will replace whatever is currently in the TextArea.
 
Patrick Mugabe
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Gregg, it works. You know your stuff.
Thanks...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic