Hi all,
I have a method in a GUI class which recieves a resultSet.
I am trying to get my existing JTable to update with data from the result set.
I can see the table columns ( I am only using 2 columns from the resultset ), however when I try to iterate I am only getting one result back to the table model. There should be more.
There are no errors during execution.
If someone could help with this issue it would be much appreciated.
Please see the code below.
public static void getResultSet(ResultSet resultSet) throws SQLException {
ResultSetMetaData metaData = resultSet.getMetaData();
Vector<String> columnNames = new Vector<String>();
int columnCount = 2;
for (int column = 1; column <= columnCount; column++) {
columnNames.add(metaData.getColumnName(column));
System.out.println("ColumnNames "+columnNames );
}
DefaultTableModel datamodel = new DefaultTableModel(columnNames, 0);
resultsTable.setModel(datamodel);
while (resultSet.next()) {
Vector<String> vector = new Vector<String>();
for (int columnIndex = 1; columnIndex <= columnCount; columnIndex++) {
vector.add(resultSet.getString(columnIndex));
}
datamodel.addRow(vector);
System.out.println("VECTOR = " +vector);