注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

0与1构筑世界,程序员创造时代

软件架构设计 Java编程

 
 
 

日志

 
 

DbUnit - 常见错误解决方法  

2009-10-12 13:49:01|  分类: Java |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
  文章声明

作者:傲风(aofengblog@163.com)       编写时间:2009年10月12日

网址:http://aofengblog.blog.163.com

作者保留所有权利,转载请保留文章全部内容!


环境

dbunit-2.4.5

一、AmbiguousTableNameException

详细的错误信息如下:
org.dbunit.database.AmbiguousTableNameException: AREA_GROUP
at org.dbunit.dataset.OrderedTableNameMap.add(OrderedTableNameMap.java:198)
at org.dbunit.database.DatabaseDataSet.initialize(DatabaseDataSet.java:227)
at org.dbunit.database.DatabaseDataSet.getTableMetaData(DatabaseDataSet.java:275)
at org.dbunit.operation.DeleteAllOperation.execute(DeleteAllOperation.java:109)
at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
at org.dbunit.AbstractDatabaseTester.executeOperation(AbstractDatabaseTester.java:190)
at org.dbunit.AbstractDatabaseTester.onSetup(AbstractDatabaseTester.java:103)
at org.dbunit.DatabaseTestCase.setUp(DatabaseTestCase.java:156)
at cn.aofeng.dbunit.PersonalTester.setUp(PersonalTester.java:40)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

DbUnit - 常见错误解决方法 - 傲风 - 解决方法:指定schema。
例如:System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_SCHEMA, "aidmcu");  


二、NoPrimaryKeyException

详细的错误信息如下:
org.dbunit.dataset.NoPrimaryKeyException: PERSONAL
at org.dbunit.operation.UpdateOperation.getOperationData(UpdateOperation.java:72)
at org.dbunit.operation.RefreshOperation$UpdateRowOperation.<init>(RefreshOperation.java:266)
at org.dbunit.operation.RefreshOperation.createUpdateOperation(RefreshOperation.java:142)
at org.dbunit.operation.RefreshOperation.execute(RefreshOperation.java:100)
at org.dbunit.AbstractDatabaseTester.executeOperation(AbstractDatabaseTester.java:190)
at org.dbunit.AbstractDatabaseTester.onSetup(AbstractDatabaseTester.java:103)
at org.dbunit.DatabaseTestCase.setUp(DatabaseTestCase.java:156)
at cn.aofeng.dbunit.PersonalTester.setUp(PersonalTester.java:42)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

DbUnit - 常见错误解决方法 - 傲风 - 解决方法:给表 PERSONAL 增加主键。


三、UnsupportedOperationException: Only one iterator allowed!

详细的错误信息如下:
java.lang.UnsupportedOperationException: Only one iterator allowed!
at org.dbunit.dataset.stream.StreamingDataSet.createIterator(StreamingDataSet.java:71)
at org.dbunit.dataset.AbstractDataSet.iterator(AbstractDataSet.java:187)
at org.dbunit.operation.AbstractBatchOperation.iterator(AbstractBatchOperation.java:93)
at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:129)
at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
at org.dbunit.AbstractDatabaseTester.executeOperation(AbstractDatabaseTester.java:190)
at org.dbunit.AbstractDatabaseTester.onSetup(AbstractDatabaseTester.java:103)
at org.dbunit.DatabaseTestCase.setUp(DatabaseTestCase.java:156)
at cn.aofeng.dbunit.PersonalTester.setUp(PersonalTester.java:41)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

DbUnit - 常见错误解决方法 - 傲风 - 原因:
XML内容格式如下:
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<table name="SRC_FW_PKG">
<column>PKG_ID</column>
<column>PKG_TYPE</column>
<column>MODEL_ID</column>
<column>MANU_ID</column>
<column>SOURCE_VER</column>
<column>TARGET_VER</column>
<column>PKG_SIZE</column>
<row>
<value>1</value>
<value>1</value>
<value>6111</value>
<value>396</value>
<value>VER1.1</value>
<value>VER1</value>
<value>396</value>
</row>
</table>
</dataset>

却用 FlatXmlDataSet 来解析。

DbUnit - 常见错误解决方法 - 傲风 - 解决方法:用 XmlDataSet 解析XML文件。
DbUnit - 常见错误解决方法 - 傲风 - 产生 UnsupportedOperationException 的有多种原因,这里的解决方法仅供参考。

<正文结束>
  评论这张
 
阅读(3192)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017