c0nnexx10n : C0nnect1ng L1fe w1th Techn010gy

Byte by Byte Impressions on Technology, People and Process !

DBUNIT, HSQLDB, data type (16, ‘BOOLEAN’) not recognized and will be ignored. See FAQ for more information.

Posted by vikashazrati on Sunday, July 29, 2007

We are using HSQLDB (1.8.0.1) as the in memory database for our DBUNIT (2.1) test cases. Suddenly when trying to insert from our XML datafile to a boolean field we started getting an error which said

WARNING – APP_USER.ACCOUNT_EXPIRED data type (16, ‘BOOLEAN’) not recognized and will be ignored. See FAQ for more information.

It looks like the SQL type Types.BOOLEAN is not handled correctly. The way around is that

  • Create a new data type factory that extends the DBUnit class DefaultDataTypeFactory like this

import java.sql.Types;

import org.dbunit.dataset.datatype.DataType;
import org.dbunit.dataset.datatype.DataTypeException;
import org.dbunit.dataset.datatype.DefaultDataTypeFactory;

/**
* @author vhazrati
*
*/
public class HsqlDataTypeFactory extends DefaultDataTypeFactory {

@Override
public DataType createDataType(int sqlType, String sqlTypeName) throws DataTypeException {
if (sqlType == Types.BOOLEAN) {
return DataType.BOOLEAN;
}

return super.createDataType(sqlType, sqlTypeName);
}
}

  • Now use this Data type factory like this in your setup

protected void setUpMemoryDatabase() {
DataSource ds = jdbcTemplate.getDataSource();
Connection con = DataSourceUtils.getConnection(ds);
IDatabaseConnection connection = new DatabaseConnection(con);
try {
DatabaseConfig config = connection.getConfig();
config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new HsqlDataTypeFactory());
IDataSet dataSet = new FlatXmlDataSet(new File(”src/test/resources/test-dataset.xml”));

DatabaseOperation.CLEAN_INSERT.execute(connection, dataSet);
} catch (Exception e) {
log.debug(e);
} finally {
try {
connection.close();
} catch (SQLException e) {
log.debug(e);
e.printStackTrace();
}
}
}

3 Responses to “DBUNIT, HSQLDB, data type (16, ‘BOOLEAN’) not recognized and will be ignored. See FAQ for more information.”

  1. Toub said

    This is exactly what does “org.dbunit.ext.hsqldb.HsqldbDataTypeFactory”, included in DBUnit (at least in 2.2 version).

  2. Jol Blazey said

    I am having exactly this problem in version dbunit 2.2, even though the dbunit site says it is fixed in release notes.

    I am still having the problem if I add the DataTypeFactory code above.

    Possible that the error message is misleading in my case.
    Jol.

  3. Chad Skeeters said

    I had this problem, but I upgraded to DBUnit 2.3.0 and it has gone away.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>