本文整理汇总了Java中org.dbunit.dataset.xml.FlatXmlWriter类的典型用法代码示例。如果您正苦于以下问题:Java FlatXmlWriter类的具体用法?Java FlatXmlWriter怎么用?Java FlatXmlWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FlatXmlWriter类属于org.dbunit.dataset.xml包,在下文中一共展示了FlatXmlWriter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import org.dbunit.dataset.xml.FlatXmlWriter; //导入依赖的package包/类
public static void main(String[] args)
throws Exception
{
//Connect to the database
Class.forName( "com.mysql.jdbc.Driver" );
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/easyrec_test", "root", "root");
IDatabaseConnection connection = new DatabaseConnection( conn );
QueryDataSet partialDataSet = new QueryDataSet(connection);
//Specify the SQL to run to retrieve the data
partialDataSet.addTable("actionarchive1", " SELECT * FROM actionarchive1");
//Specify the location of the flat file(XML)
// file is stored in /target folder
FlatXmlWriter datasetWriter = new FlatXmlWriter(new FileOutputStream("easyrec-testutils/target/temp.xml"));
//Export the data
datasetWriter.write( partialDataSet );
}
开发者ID:major2015,项目名称:easyrec_major,代码行数:22,代码来源:DbUnitSqlToXmlExporter.java
示例2: extract
import org.dbunit.dataset.xml.FlatXmlWriter; //导入依赖的package包/类
/**
* Performs the extraction. If no tables or queries are specified, data from
* entire database will be extracted.
* Otherwise, a partial extraction will be performed.
*
* @throws Exception
*/
public void extract() throws Exception {
Connection conn = null;
try {
conn = dataSource.getConnection();
logger.info("Beginning extraction from '" + conn.toString() + "'.");
IDatabaseConnection connection = new DatabaseConnection(conn, schema);
configConnection((DatabaseConnection) connection);
if (tableList != null || queryList != null) {
// partial database export
QueryDataSet partialDataSet = new QueryDataSet(connection);
addTables(partialDataSet);
addQueries(partialDataSet);
FlatXmlDataSet.write(partialDataSet, new FileOutputStream(dataSetName));
} else {
// full database export
IDataSet fullDataSet = connection.createDataSet();
FlatXmlDataSet.write(fullDataSet, new FileOutputStream(dataSetName));
// dependent tables database export: export table X and all
// tables that
// have a PK which is a FK on X, in the right order for
// insertion
String[] depTableNames = TablesDependencyHelper.getAllDependentTables(connection, "research");
IDataSet depDataset = connection.createDataSet(depTableNames);
FlatXmlWriter datasetWriter = new FlatXmlWriter(new FileOutputStream("target/dependents.xml"));
datasetWriter.write(depDataset);
}
} finally {
if (conn != null) {
conn.close();
}
}
logger.info("Completed extraction to '" + dataSetName + "'.");
}
开发者ID:antoniomaria,项目名称:gazpachoquest,代码行数:44,代码来源:DBUnitDataExtractor.java
示例3: write
import org.dbunit.dataset.xml.FlatXmlWriter; //导入依赖的package包/类
public void write(IDataSet dataSet, WriteTarget writeTarget)
throws DataSetException, IOException {
OutputStream outputStream = writeTarget.getAdapter(OutputStream.class);
try {
FlatXmlWriter flatXmlWriter = new FlatXmlWriter(outputStream);
flatXmlWriter.write(dataSet);
} finally {
IOUtils.closeQuietly(outputStream);
}
}
开发者ID:link-intersystems,项目名称:maven,代码行数:11,代码来源:FlatXmlDataSetWriter.java
注:本文中的org.dbunit.dataset.xml.FlatXmlWriter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论