Subject Getting BLOBs from FB-Database with JayBird
Author Schmitt, Christian
Hello JayBird Community,

we've got a problem retrieving BLOBs from my Database with JayBird.
Inserting of BLOBs worked just fine and we can see the BLOBs with the
ISQL-Tool from Firebird. But when we try to get the BLOBs with Jaybird,
the FBResultSet contains no binary data.

The fields are recognized correctly as FBIntegerField and FBBlobField,
but the method getBytes(long,int) of FBBlob throws a SQLException:

"Couldn't retrieve binary data: org.firebirdsql.jdbc.FBSQLException: I/O
Exception. Invalid BLOB type for operation"

We tried every BLOB type for the database table field, but the exception
is always the same. The data we have to access after the test are all
self defined type '-1'. Is there a way to define the type for the
current transaction? How can we successfully get the BLOB data from the

We're using following equipment:
Firebird Database:
- Classic Server on Windows
- Super Server on SuSE Linux 10.2

- SuSE Linux 10.0, Java (Sun) 1.5.0_03-b07, Jaybird 2.1.1, JBuilder 2006

Source Code:
- 1st try: See JayBird FAQ example
- 2nd try: See below

Statement smnt = fbconn.createStatement();
ResultSet rset = smnt.executeQuery("SELECT rowed, rowdata FROM blob
WHERE rowed=1"); If ( ){
FBBlob fbblob = (FBBlob)rset.getBlob(2);
Byte[] bytes = fbblob.getBytes(0,80); // <-- throws exception
(Segmentation is 80, real data we have to access are segmentation 40) }
return bytes;

Thanks for your help. :-)

Sincerely yours
Christian Schmitt

Forschungszentrum Karlsruhe -
Institute for Applied Computer Science -
Karlsruhe Institute of Technology -