Hello, I am working on a school project. I want to generate a list of customers from a database and display it on the screen.
I have code written to get the records from the database as follows:
|
Code:
|
public static Vector getAll() {
Vector customers = new Vector();
String query = "SELECT * FROM Customer ";
try {
ResultSet rs = stmt.executeQuery(query);
boolean more = rs.next();
while(more) {
String fname = rs.getString(2);
String lname = rs.getString(3);
String address = rs.getString(4);
String city = rs.getString(5);
String state = rs.getString(6);
String zipcode = rs.getString(7);
String phone = rs.getString(8);
aCustomer = new Customer(fname, lname, address, city, state, zipcode, phone);
customers.addElement(aCustomer);
more = rs.next();
}
rs.close();
}
catch (SQLException e) {
System.out.println(e);
}
return customers;
} |
Assuming that code is correct, I should have a vector that contains all records in the database. Now I just want to generate a list from this vector that displays the customers first and last name. I'm not sure how to go about this, so could somebody please help??????
Thanks