org.dbunit.dataset.datatype.TypeCastException: Error casting value for table 'foo.bar' and column 'CREATED_ON'
at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:190)
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)
This was caused by:
Caused by: org.dbunit.dataset.datatype.TypeCastException: Unable to typecast value <2010-20-10 10:30:45> of type <java.lang.String> to DATE
at org.dbunit.dataset.datatype.DateDataType.typeCast(DateDataType.java:106)
at org.dbunit.dataset.datatype.DateDataType.setSqlValue(DateDataType.java:141)
at org.dbunit.database.statement.SimplePreparedStatement.addValue(SimplePreparedStatement.java:73)
at org.dbunit.database.statement.AutomaticPreparedBatchStatement.addValue(AutomaticPreparedBatchStatement.java:63)
at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:186)
... 42 more
Caused by: java.lang.IllegalArgumentException
at java.sql.Date.valueOf(Date.java:140)
at org.dbunit.dataset.datatype.DateDataType.typeCast(DateDataType.java:102)
Java 7 on Windows 7.
Still a problem?
Just attempted a build w/ Java 7 and received unit test failure, so appears to still be issue:
Tests run: 14, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.006 sec <<< FAILURE! - in org.dbunit.dataset.datatype.TimestampDataTypeTest
testCompareDifferent(org.dbunit.dataset.datatype.TimestampDataTypeTest) Time elapsed: 0.001 sec <<< ERROR!
org.dbunit.dataset.datatype.TypeCastException: Unable to typecast value <1974-23-06 23:40:00.0> of type <java.lang.string> to TIMESTAMP
at java.sql.Timestamp.valueOf(Timestamp.java:235)
at org.dbunit.dataset.datatype.TimestampDataType.typeCast(TimestampDataType.java:116)
at org.dbunit.dataset.datatype.AbstractDataType.compare(AbstractDataType.java:82)
at org.dbunit.dataset.datatype.TimestampDataTypeTest.testCompareDifferent(TimestampDataTypeTest.java:273)</java.lang.string>
Further investigation reveals that it appears to be locale related. The test string is yyy-dd-mm (1974-23-06 23:40:00.0), which gives me the following:
java.lang.IllegalArgumentException: Timestamp format
must be yyyy-mm-dd hh:mm:ss[.fffffffff]
Even further investigation reveals that JDK 6 also expected this format, but additional validation was added to Timestamp.valueOf in 7, throwing additional exceptions.
Last edit: Kyle Moore 2014-06-19
This hasn't been a problem for some time so closing.