Subject Re: Invalid Blob ID when inserting blob?
Author phil_hhn
--- In, "Roman Rokytskyy"
<rrokytskyy@a...> wrote:
> The record in Firebird contains only a BLOB ID, a reference to the
> BLOB. When one tries to insert a record with non-existing ID, it
will fail.
> However without code I cannot even guess why the server is denying your
> call.

We have a Vector which contains elements of 'StringPair' (a class
which is simply a pair or Strings). In this case the Vector includes
one StringPair. My code:
PreparedStatement ps = MyConnection.prepareStatement("UPDATE CAMPUS
ps.setObject(1, MyVector);

This fails with the error
"org.firebirdsql.jdbc.field.TypeConvertionException: Error converting
to object".
If I read the JDK correctly, setObject may only be used with a
java.sql.Type object? Can you confirm that?

So I had then written my own method which serialises the Vector to a
byte[] then calls ps.setBytes(1, byte[]). Because this is the only
column in the prepared statement, the method also called ps.execute().
But I'd forgotten this, and the caller was calling ps.execute() also!
I've taken out the second ps.execute() and now there is no error.
I had read that the blob is really only a pointer to the actual binary
object being stored; so I guess that explains the message referring to
a 'Blob ID'. I never intend to call execute() twice on the same
prepared statement (without clearing parameter(s) if re-using); but in
this case - although it's accidental - I'm wondering (only out of
curiousity) what's going on internally here? Can someone explain the

Thanks Roman