Unitils数据集 - 插入sybase datetime列

时间:2013-01-02 12:09:03

标签: datetime dataset sybase unitils

我有一个单元数据集试图将数据输入到sybase datetime列,但是当我尝试运行单元测试时它会出错。

我在网上找不到有关插入日期的内容,所以我尝试将其声明为与其他列相同的字符串,但我收到错误:

org.unitils.core.UnitilsException: Error inserting test data from DbUnit dataset for method etc etc
    at org.unitils.dbunit.DbUnitModule.insertDataSet(DbUnitModule.java:156)
    at org.unitils.dbunit.DbUnitModule$DbUnitListener.beforeTestSetUp(DbUnitModule.java:556)
    at org.unitils.core.Unitils$UnitilsTestListener.beforeTestSetUp(Unitils.java:273)
    at org.unitils.UnitilsJUnit4TestClassRunner$TestListenerInvokingMethodRoadie.runBeforesThenTestThenAfters(UnitilsJUnit4TestClassRunner.java:151)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:84)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
    at org.unitils.UnitilsJUnit4TestClassRunner.invokeTestMethod(UnitilsJUnit4TestClassRunner.java:95)
    at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:61)
    at org.unitils.UnitilsJUnit4TestClassRunner.access$000(UnitilsJUnit4TestClassRunner.java:44)
    at org.unitils.UnitilsJUnit4TestClassRunner$1.run(UnitilsJUnit4TestClassRunner.java:62)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
    at org.unitils.UnitilsJUnit4TestClassRunner.run(UnitilsJUnit4TestClassRunner.java:68)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.unitils.core.UnitilsException: Error while executing DataSetLoadStrategy
    at org.unitils.dbunit.datasetloadstrategy.impl.BaseDataSetLoadStrategy.execute(BaseDataSetLoadStrategy.java:46)
    at org.unitils.dbunit.DbUnitModule.insertDataSet(DbUnitModule.java:230)
    at org.unitils.dbunit.DbUnitModule.insertDataSet(DbUnitModule.java:153)
    ... 18 more
Caused by: org.dbunit.dataset.datatype.TypeCastException: Error casting value for table 'USER' and column 'SUSPEND_SD'
    at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:202)
    at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:78)
    at org.unitils.dbunit.datasetloadstrategy.impl.CleanInsertLoadStrategy.doExecute(CleanInsertLoadStrategy.java:45)
    at org.unitils.dbunit.datasetloadstrategy.impl.BaseDataSetLoadStrategy.execute(BaseDataSetLoadStrategy.java:44)
    ... 20 more

在我的数据集中插入日期的唯一行是:

<USER ID="4" FULL_NAME="user3" SUSPEND_SD="25/12/2011 00:00" SUSPEND_ED="25/12/2013 00:00" PASSWORD="password3"/>

有人可以帮忙吗?

提前致谢。

1 个答案:

答案 0 :(得分:0)

我不知道单位是如何工作的,但假设您的数据集是可编辑的,为什么不将日期更改为yyyy / mm / dd格式。

那个java堆栈提到了转换,这对于我想到的日期时间dd / mm / yyyy来说是一个失败。

或者中间件可能有一些日期配置方式 - 你可以告诉它日期是英国的(甚至可能是区域设置?)