1

I have to test a class where we are retrieving data from Oracle, from a XMLTYPE column. We are using BLOB for the casting, because the system is prepared to run in MySQL too:

BLOB salePlanXmlType = (BLOB) jdsLoad.getValueCell(0, "SALEPLAN");

In DBUnit, first we are creating the tables, and then loading data. The loading part was fun, but I managed to load two XML's using the tips found here.

Anyway I can't manage to create a table in DBUnit with a BLOB type. Here's the script I try to execute:

CREATE TABLE TSHT_SALEPLAN
(
  SALEPLANCODE  INTEGER,
  VENDORCODE    VARCHAR(10),
  HOTELCODE     INTEGER,
  SALEPLAN      BLOB
); 

When I run the test with this script, I get the following error:

java.sql.SQLException: Wrong data type: BLOB in statement 
[CREATE TABLE     TSHT_SALEPLAN
(
  SALEPLANCODE  INTEGER,
  VENDORCODE      VARCHAR(10),
  HOTELCODE     INTEGER,
  SALEPLAN      BLOB]
    at org.hsqldb.jdbc.Util.throwError(Unknown Source)
    at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)

Which I don't understand, because BLOB seems to be supported by hsqldb.

If I change the BLOB column definition and use VARBINARY, it works. But then the casting to Blob in my code throws an exception.

Has anybody used BLOB in a create table statement with DBUnit?

1 Answer 1

2

The exception is from an old version of HSQLDB (probably 1.8) that does not support BLOB. Use the latest version 2.3.x jar instead.

Sign up to request clarification or add additional context in comments.

1 Comment

Many thanks! Seeing the solution, I wonder why I didn't thought about it. Anyway, it works now (with version 2.3.2)!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.