This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Using ResultSet" Watch "Using ResultSet" New topic

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:
rs2 = stat.executeQuery(select2);
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

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.
I agree. Here's the link:
subject: Using ResultSet
Similar Threads
CSV file structure Validation
ResultSet multiple line query exception
Please help with GUI
IText Problem
Creating JPanel