* @param xmlFilePaths 符合Spring Resource路径格式的文件列表.
*/
private static void execute(DatabaseOperation operation, DataSource dataSource, String... xmlFilePaths)
throws DatabaseUnitException, SQLException {
//注意这里HardCode了使用H2的Connetion
IDatabaseConnection connection = new H2Connection(dataSource.getConnection(), null);
for (String xmlPath : xmlFilePaths) {
try {
InputStream input = resourceLoader.getResource(xmlPath).getInputStream();
IDataSet dataSet = new FlatXmlDataSetBuilder().setColumnSensing(true).build(input);
operation.execute(connection, dataSet);
} catch (IOException e) {
logger.warn(xmlPath + " file not found", e);
}finally{
connection.close();
}
}
}