GeeCON Prague 2014*
The moose likes JDBC and the fly likes Using ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "Using ResultSet" Watch "Using ResultSet" New topic
Author

Using ResultSet

Patrick Mugabe
Ranch Hand

Joined: Jan 08, 2002
Posts: 132
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
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.


GenRocket - Experts at Building Test Data
Patrick Mugabe
Ranch Hand

Joined: Jan 08, 2002
Posts: 132
Thanks a lot Gregg, it works. You know your stuff.
Thanks...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using ResultSet