How to read blob data from HSQL Database



Just wondering if anyone can help me to query the database and convert blob data into a readable format.

  1. I wrote a simple Java application to connect to database

conn = DriverManager.getConnection(“jdbc:hsqldb:”+db_file_name,“username”,“password”);

  1. I then created a select query on EXG_EXCHANGE table

  2. I tried converting to a string and printed out and I tried calling getBlob method but all I get back is ascii code.

My last attempt was the following code:

blob = rs.getBlob(“DETAIL”);

in = new BufferedReader(new InputStreamReader(blobInputStream));
while ((str=in.readLine()) !=null) {
fullBlobText +=str;


I am taking a guess here. Is the blob data stored in database fields a Joda object?


Or is it a Fudge Message and how do I extract the blob and convert the fudge message to readable content?


Well, the answers are all in DbExchangeMaster which is the class we’d recommend you use to read the database. Not sure why you’re not using the existing tested class?

(The source code will tell you that it stores Fudge binary data, and there are specific helper classes for reading/writing the blob, but as the approach varies by database, it is abstracted)


Where can I find the helper classes for reading/writing the blob? Do you have any basic tutorials/examples that can assist my learning curve?


The blob is written using:
byte[] bytes = FUDGE_CONTEXT.toByteArray(env.getMessage());
new SqlLobValue(bytes, getDialect().getLobHandler()), Types.BLOB)
where the dialect is an instance of DbDialect.

The blob is read using:
byte[] bytes = lob.getBlobAsBytes(rs, “DETAIL”);
ManageableExchange exchange = FUDGE_CONTEXT.readObject(ManageableExchange.class, new ByteArrayInputStream(bytes));