當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。