使用dbunit向数据库中插入xml数据
来源:互联网 发布:sql server 列转行 编辑:程序博客网 时间:2024/05/21 05:55
java code:
IDatabaseConnection connection = null;
try {
if(schema !=null && schema.trim().length()>0)
connection = new DatabaseConnection(DriverManager.getConnection(url, user, password),schema);
else
connection = new DatabaseConnection(DriverManager.getConnection(url, user, password));
File dataFile = new File(resource);
if(!dataFile.exists() || !dataFile.isFile()){
throw new IllegalArgumentException("invalidate dataset file.");
}
IDataSet dataSet = new FlatXmlDataSet(dataFile);
DatabaseOperation.CLEAN_INSERT.execute(connection, dataSet);
} finally{
if(connection != null){
connection.close();
}
}
xml:
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<table_name colName="value" [colName="value"] />
</dataset>
IDatabaseConnection connection = null;
try {
if(schema !=null && schema.trim().length()>0)
connection = new DatabaseConnection(DriverManager.getConnection(url, user, password),schema);
else
connection = new DatabaseConnection(DriverManager.getConnection(url, user, password));
File dataFile = new File(resource);
if(!dataFile.exists() || !dataFile.isFile()){
throw new IllegalArgumentException("invalidate dataset file.");
}
IDataSet dataSet = new FlatXmlDataSet(dataFile);
DatabaseOperation.CLEAN_INSERT.execute(connection, dataSet);
} finally{
if(connection != null){
connection.close();
}
}
xml:
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<table_name colName="value" [colName="value"] />
</dataset>
- 使用dbunit向数据库中插入xml数据
- 向数据库中插入数据:
- ADO.Net:使用DataReader向数据库中插入数据
- 向derby数据库中插入数据
- 向数据库中批量插入数据
- JDBC向数据库中插入数据
- 向数据库中插入多条数据
- 向数据库中插入日期数据
- asp中向数据库不能插入数据
- 向数据库中循环插入数据
- php 向数据库表中插入数据
- 使用事务向SqlServer中插入数据
- 在SQL语句中使用参数向数据库中插入含特殊字符的数据
- Esper(二) 数据库篇 2 向数据库中插入数据
- java向数据库中插入数据,数据库乱码问题解决
- DBUnit插入数据(准备)
- javaWeb使用servlet并且连接数据库向数据库插入数据
- c#向数据库中插入xml数据类型的字段
- 1046. Plane Spotting排序
- 频谱和波段划分
- BOOST的Singleton模版详解
- Xmanager连接CentOS6
- 1051. Biker's Trip Odomete简单题
- 使用dbunit向数据库中插入xml数据
- 1176. Two Ends两人从两头取数
- gethibernatetemplate的find方法使用说明
- ant ftp 使用
- 如何在Visual Studio中打开REST SOE模板
- 1198. Substring 8个串排出最小字典序(8!枚举)
- 制定自己 ant 标签
- Message Modem Develop
- 1006.Team Rankings 栈与回溯 简单 5!搜索