Subject JayBird NullPointerException BUG?
Author alonsong2002
I'm using a preparedStatement to insert a lot of rows. The table
contains a BLOB field. Some times the BLOB value to insert is null.

The executeUpdate fails some times, but i can't find the exact
reason. If the parametrer value for the BLOB si NOT null it works
all the time. If the parameter value for the BLOB is null it fails
SOME times. Probably that's not the reason but it might be a clue.

The NullPointerException is caused because JayBird tries to create a
ByteArrayInputStream with a null input buffer array parameter. You
can see this in the stackTrace (ByteArrayInputStream.java:85).

One other thing, I'm using preparedStatement.setNull(2,-4) to set
the null value for the BLOB. And preparedStatement.setObject
(byteArray, -4) to set the byte array value for the BLOB.

Workarround: if i recreate the prepared statement and set the same
parameters it works again for a while and the problem repeats
(randomly?).

Here is the statement (ItemDesc_STYPHOTO is the BLOB):

INSERT INTO MQ_25359 (ItemDesc_ITEMS_ID , ItemDesc_STYPHOTO ,
ItemDesc_STYLE , ItemDesc_COLOR , ItemDesc_SSIZE ,
ItemDesc_SECSIZE , CompStock_ITEMS_ID , CompStock_LASTSALEDATE ,
CompStock_QTY_SUM) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)

And this is the exception:

java.lang.NullPointerException
at java.io.ByteArrayInputStream.<init>
(ByteArrayInputStream.java:85)
at org.firebirdsql.jdbc.FBBlobField.flushCachedData
(FBBlobField.java:268)
at org.firebirdsql.jdbc.FBPreparedStatement.internalExecute
(FBPreparedStatement.java:415)
at org.firebirdsql.jdbc.FBPreparedStatement.executeUpdate
(FBPreparedStatement.java:137)
at com.caffelatte.db.QueryExecuter.merge
(QueryExecuter.java:347)

Thanks for your help.