Subject Re: Poor Blob implementation.. snif....
Author Roman Rokytskyy
Hi,

> I'm trying to use JBird with OJB (from apache jakarta).
> Unfortunely, the method setEscapeProcessing(boolean) is not
> supported. As I don't know what it intend to do, I comment all the
> lines with this statement in OJB.... and it work fine !!...

Thanks for pointing this out! I have implemented this method and
committed to CVS.

> until I
> tryed to use a Bolb type field.
>
> here is the lines wich are problematic :
> static Object getObjectFromColumn(ResultSet rs, int jdbcType, int
> columnId) throws SQLException
> {
> Object result = null;
> switch (jdbcType)
> {
> case Types.BIT :
> {
> result = new Boolean(rs.getBoolean(columnId));
> break;
> }
> case Types.TINYINT :
> {
> byte val = rs.getByte(columnId);
> if (!rs.wasNull())
> result = new Byte(val);
> break;
> }
> ...
>
> ...
> case Types.BLOB :
> {
> java.sql.Blob aBlob = rs.getBlob(columnId);
> result = aBlob.getBytes(1L, (int) aBlob.length());
> break;
> }
> default :
> {
> throw new RuntimeException(
> "The type "
> + jdbcType
> + " for attribute "
> + columnId
> + " can not be handled by OJB. Please specify only types
> as defined by java.sql.Types.");
> }
> }
> return result;
> }
>
>
> At first, the getBlob method of ResultSet class return null if the
> blob field is empty. That's not seems to be the same in others JDBC
> connectors (there is no test here).

I wrote a test case that stores empty blob (byte[0]) and null blob. I
was able to read them back correctly. You will find this test case in
CVS in client-java/src/test/org/firebirdsql/jdbc/TestFBBlobAutocommit.java

According to the specification all getXXX methods that return subclass
of java.lang.Object must return null if the underlying column value is
null. If other drivers return you non-null value, this is not correct.

> Second, the length method of Blob class is not implemented !

Unfortunatelly we do not have complete Firebird API implemented. We
are still missing some methods, isc_blob_info() is among them.

> That's too much for me. I decide to stop the use of Blob. Too bad.

We correctly support getBytes(int) and getBinaryStream(int) methods,
so our driver should work for BINARY type (which is default for BLOB
SUB_TYPE 0 type in Firebird, java.sql.Blob is default only for blobs
with subtype < 0).

> So what is the road map for the complete implementation of the blob
> support ?

As far as I know, no exact plans exist. Right now we are working on
release version of this driver. We do not plan to implement new API
calls before release. This means that some features will not be in
release version. java.sql.Blob.length() among them.

Best regards,
Roman Rokytskyy