Resultset get all values

ResultsetMetaData holds your column count too. The snippet below will fill out an Object array for every column in a resultset.

The API doc is your friend: http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.html http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSetMetaData.html

ResultSet resultSet = getResultSetFromSomewhere();
ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
final int columnCount = resultSetMetaData.getColumnCount();

while (resultSet.next()) {
    Object[] values = new Object[columnCount];
    for (int i = 1; i <= columnCount; i++) {
        values[i - 1] = resultSet.getObject(i);
    }
    model.addRow(values);
}

For every rs.next():

Object[] row = new Object[columnCount];
for (int i = 1; i <= columnCount; ++i) {
    row[i - 1] = rs.getString(i); // Or even rs.getObject()
}
model.addRow(row);