• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FlatXmlWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Level类代码示例发布时间:2022-05-22
下一篇:
Java RedirectAttributesModelMap类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap