当前位置: 首页>>代码示例>>Java>>正文


Java DatabaseOperation.execute方法代码示例

本文整理汇总了Java中org.dbunit.operation.DatabaseOperation.execute方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseOperation.execute方法的具体用法?Java DatabaseOperation.execute怎么用?Java DatabaseOperation.execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.dbunit.operation.DatabaseOperation的用法示例。


在下文中一共展示了DatabaseOperation.execute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.dbunit.operation.DatabaseOperation; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    initialDataSet = new FlatXmlDataSetBuilder().build(new File("src/test/resources/test-data.xml"));
    connection = new DatabaseConnection(DriverManager.getConnection(CONNECTION_URL, USER_NAME, PASSWORD));

    final DatabaseOperation operation = DatabaseOperation.CLEAN_INSERT;
    operation.execute(connection, initialDataSet);

    connection.getConnection().createStatement().execute(
            "insert into XML_TABLE_1(id, version, value_1, value_2, value_3, value_4, value_5) values(10, 'Record 10 version', 'Record 10 Value 1', 'Record 10 Value 2', 'Record 10 Value 3', 'Record 10 Value 4', 'Record 10 Value 5');");
    connection.getConnection().commit();

    connection.getConnection().createStatement().execute(
            "merge into XML_TABLE_3(id, version, value_8, value_9) values(11, 'Record 11 version', 'Record 11 Value 8', 'Record 11 Value 9');");
    connection.getConnection().commit();

    assertThat(getRecordCountFromTable(connection, "XML_TABLE_1"), equalTo(4));
    assertThat(getRecordCountFromTable(connection, "XML_TABLE_2"), equalTo(1));
    assertThat(getRecordCountFromTable(connection, "XML_TABLE_3"), equalTo(1));
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:21,代码来源:CleanupStrategyProviderTest.java

示例2: execute

import org.dbunit.operation.DatabaseOperation; //导入方法依赖的package包/类
/**
 * 对XML文件中的数据在H2数据库中执行Operation.
 * 
 * @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();
		}
	}
}
 
开发者ID:extion,项目名称:base-framework,代码行数:23,代码来源:Fixtures.java

示例3: createSeedDataFeature

import org.dbunit.operation.DatabaseOperation; //导入方法依赖的package包/类
@Override
protected DbFeature<IDatabaseConnection> createSeedDataFeature(final DataSeedStrategy dataSeedStrategy,
        final List<IDataSet> initialDataSets) {
    return (final IDatabaseConnection connection) -> {
        try {
            final DatabaseOperation operation = dataSeedStrategy.provide(providerFactory.createDataSeedStrategyProvider());
            operation.execute(connection, mergeDataSets(initialDataSets));
        } catch (DatabaseUnitException | SQLException e) {
            throw new DbFeatureException("Could not execute DB seed feature", e);
        }
    };
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:13,代码来源:SqlDbFeatureExecutor.java

示例4: with

import org.dbunit.operation.DatabaseOperation; //导入方法依赖的package包/类
/**
 * @author Wasiq B
 * @since 24-Nov-2015 8:51:44 pm
 * @param operation
 * @throws FrameworkException
 */
public void with (final DatabaseOperation operation) throws FrameworkException {
	try {
		log.entry ();
		final DatabaseOperation refresh = new InsertIdentityOperation (operation);
		refresh.execute (getConnection (), getDataSet ());
	}
	catch (final Exception e) {
		log.catching (e);
		throw new FrameworkException ("with", e);
	}
	finally {
		log.exit ();
	}
}
 
开发者ID:WasiqB,项目名称:xtesy-framework,代码行数:21,代码来源:DataSetBuilder.java

示例5: execute

import org.dbunit.operation.DatabaseOperation; //导入方法依赖的package包/类
/**
 * Executes DbUnit <code>operation</code> on dataset
 * <code>dataSetSource</code>.
 */
protected void execute(DatabaseOperation operation, DataSetSource dataSetSource) {
	IDatabaseConnection dbconn = null;
	try {
		dbconn = connectionCreator.create();
		operation.execute(dbconn, findDataSet(dataSetSource));
	} catch (Exception e) {
		throw new IllegalStateException(
				"It's not possible to execute DbUnit operation: " 
						+ e.getMessage(), e);
	} finally {
		connectionCreator.close(dbconn);
	}
}
 
开发者ID:rponte,项目名称:dbunitmanager,代码行数:18,代码来源:DefaultDbUnitManagerImpl.java


注:本文中的org.dbunit.operation.DatabaseOperation.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。