private static int doStatements(
        DatabaseConnection connection,
        String label,
        Collection<String> statements,
        boolean ignoreErrors,
        boolean returnsNegative,
        boolean expectingZero)
        throws SQLException
    {
        int stmtC = 0;
        for (String statement : statements)
        {
            int rowC = 0;
            CompiledStatement compiledStmt = null;
            try
            {
                compiledStmt = connection
                        .compileStatement(statement,
                                          StatementType.EXECUTE,
                                          noFieldTypes);
                rowC = compiledStmt.runExecute();
                logger.info("executed {} table statement changed {} rows: {}",
                            label,
                            rowC,
                            statement);
            }
            catch (SQLException e)
            {
                if (ignoreErrors)
                {
                    logger.info("ignoring {} error '{}' for statement: {}",
                                label,
                                e,
                                statement);
                }
                else
                {
                    throw SqlExceptionUtil.create("SQL statement failed: "
                                                  + statement, e);
                }
            }
            finally
            {
                if (compiledStmt != null)
                {
                    compiledStmt.close();
                }
            }
            // sanity check
            if (rowC < 0)
            {
                if (!returnsNegative)
                {
                    throw new SQLException("SQL statement "
                                           + statement
                                           + " updated "
                                           + rowC
                                           + " rows, we were expecting >= 0");
                }
            }
            else if (rowC > 0 && expectingZero)
            {
                throw new SQLException("SQL statement updated "
                                       + rowC
                                       + " rows, we were expecting == 0: "
                                       + statement);
            }
            stmtC++;
        }
        return stmtC;
    }