columnNames.add(rs.getMetaData().getColumnName(i+1));
}
List<Change> changes = new ArrayList<Change>();
while (rs.next()) {
InsertDataChange change = new InsertDataChange();
if (outputControl.getIncludeCatalog()) {
change.setCatalogName(table.getSchema().getCatalogName());
}
if (outputControl.getIncludeSchema()) {
change.setSchemaName(table.getSchema().getName());
}
change.setTableName(table.getName());
// loop over all columns for this row
for (int i = 0; i < columnNames.size(); i++) {
ColumnConfig column = new ColumnConfig();
column.setName(columnNames.get(i));
Object value = JdbcUtils.getResultSetValue(rs, i + 1);
if (value == null) {
column.setValue(null);
} else if (value instanceof Number) {
column.setValueNumeric((Number) value);
} else if (value instanceof Boolean) {
column.setValueBoolean((Boolean) value);
} else if (value instanceof Date) {
column.setValueDate((Date) value);
} else { // string
column.setValue(value.toString().replace("\\", "\\\\"));
}
change.addColumn(column);
}
// for each row, add a new change
// (there will be one group per table)