*/
class DbRowResultSetHandler implements ResultSetHandler<DbRowsImpl> {
@Override
public DbRowsImpl handle(ResultSet rs) throws SQLException {
DbRowsImpl dbRows = new DbRowsImpl();
ResultSetMetaData rsmd = rs.getMetaData();
while (rs.next()) {
if (rsmd == null) rsmd = rs.getMetaData();
DbRowBuilder rowBuilder = DbRowUtils.newDbRow();
for (int i = 1; i <= rsmd.getColumnCount(); i++) {
rowBuilder.addValue(rsmd.getColumnName(i), rsmd.getColumnType(i), this.processValue(rs.getObject(i)));
}
dbRows.addRow(rowBuilder.getRow());
}
// Set base row if query yielded no rows
if (dbRows.getRowCount() == 0) {
DbRowBuilder rowBuilder = DbRowUtils.newDbRow();
for (int i = 1; i <= rsmd.getColumnCount(); i++) {
rowBuilder.addValue(rsmd.getColumnName(i), rsmd.getColumnType(i), null);
}
dbRows.setBaseRow(rowBuilder.getRow());
}
return dbRows;
}