Menu

#1 Misealing exception message upon DB truncation

open
nobody
4
2010-10-25
2010-10-25
Jakub Holý
No

When DB initialization fails because data for a field is larger then its schema definition allows, a misleading exception regarding nonexistant schema is thrown and the cause must be check to find the real error.:

[WARN] EmbeddedDbTester - If the initial DB cleanup failed because of nonexistant schema (usually same as logged-in user name, for derby SA), set the System property PropertiesBasedJdbcDatabaseTester.DBUNIT_SCHEMA to an existing schema.
Error: A truncation error was encountered trying to shrink CHAR 'ManagerCnum' to length 10. <java.sql.SQLException: A truncation error was encountered trying to shrink CHAR 'ManagerCnum' to length 10.>java.sql.SQLException: A truncation error was encountered trying to shrink CHAR 'ManagerCnum' to length 10.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(Unknown Source)
at org.dbunit.database.statement.SimplePreparedStatement.addBatch(SimplePreparedStatement.java:67)
at org.dbunit.database.statement.AutomaticPreparedBatchStatement.addBatch(AutomaticPreparedBatchStatement.java:57)
at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:187)
at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:67)
at org.dbunit.AbstractDatabaseTester.executeOperation(AbstractDatabaseTester.java:132)
at org.dbunit.AbstractDatabaseTester.onSetup(AbstractDatabaseTester.java:60)
at net.jakubholy.testing.dbunit.embeddeddb.impl.EnhancedDatabaseTesterDecorator.onSetup(EnhancedDatabaseTesterDecorator.java:153)
at net.jakubholy.testing.dbunit.embeddeddb.EmbeddedDbTester.onSetup(EmbeddedDbTester.java:491)
at com.ibm.education.saba.interfaces.batch.master.extract.jdbc.JdbcPersonExtractorImplTest.setUp(JdbcPersonExtractorImplTest.java:34)
...
Caused by: ERROR 22001: A truncation error was encountered trying to shrink CHAR 'ManagerCnum' to length 10.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.iapi.types.SQLChar.hasNonBlankChars(Unknown Source)
at org.apache.derby.iapi.types.SQLChar.normalize(Unknown Source)
at org.apache.derby.iapi.types.SQLChar.normalize(Unknown Source)
at org.apache.derby.iapi.types.DataTypeDescriptor.normalize(Unknown Source)
at org.apache.derby.impl.sql.execute.NormalizeResultSet.normalizeRow(Unknown Source)
at org.apache.derby.impl.sql.execute.NormalizeResultSet.getNextRowCore(Unknown Source)
at org.apache.derby.impl.sql.execute.DMLWriteResultSet.getNextRowCore(Unknown Source)
at org.apache.derby.impl.sql.execute.InsertResultSet.open(Unknown Source)
at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
... 35 more

Version: 1.1.0

Discussion


Log in to post a comment.