public void execute(IDatabaseConnection connection, IDataSet dataSet)
throws DatabaseUnitException, SQLException
{
DatabaseConfig databaseConfig = connection.getConfig();
IStatementFactory factory = (IStatementFactory)databaseConfig.getProperty(
DatabaseConfig.PROPERTY_STATEMENT_FACTORY);
// for each table
ITableIterator iterator = iterator(dataSet);
while (iterator.next())
{
ITable table = iterator.getTable();
// Do not process empty table
if (isEmpty(table))
{
continue;
}
ITableMetaData metaData = getOperationMetaData(connection,
table.getTableMetaData());
BitSet ignoreMapping = null;
OperationData operationData = null;
IPreparedBatchStatement statement = null;
try
{
// For each row
int start = _reverseRowOrder ? table.getRowCount() - 1 : 0;
int increment = _reverseRowOrder ? -1 : 1;
try
{
for (int i = start; ; i = i + increment)
{
int row = i;
// If current row have a diffrent ignore value mapping than
// previous one, we generate a new statement
if (ignoreMapping == null || !equalsIgnoreMapping(ignoreMapping, table, row))
{
// Execute and close previous statement
if (statement != null)
{
statement.executeBatch();
statement.clearBatch();
statement.close();
}
ignoreMapping = getIgnoreMapping(table, row);
operationData = getOperationData(metaData, ignoreMapping, connection);
statement = factory.createPreparedBatchStatement(
operationData.getSql(), connection);
}
// for each column