Re: can't write a BLOB, 7.1.2 - Mailing list pgsql-jdbc

From Dejan Vucinic
Subject Re: can't write a BLOB, 7.1.2
Date
Msg-id F131sseOYqFlro9ZAqH0000476e@hotmail.com
Whole thread Raw
In response to can't write a BLOB, 7.1.2  ("Dejan Vucinic" <hotdejan@hotmail.com>)
Responses Re: can't write a BLOB, 7.1.2
List pgsql-jdbc
>"Dejan Vucinic" <hotdejan@hotmail.com> writes:
> > I'm trying to create a BLOB with the 7.1.2 JDBC driver and both
> > setBytes() and setBinaryStream() fail with this message:
> >   FastPath call returned ERROR:  lo_write: invalid large obj descriptor
>(0)

>From: Tom Lane <tgl@sss.pgh.pa.us>
>Probably you are not wrapping the operation into a transaction
>(BEGIN/COMMIT).  Large object descriptors are only good to the end of
>the current transaction.

I believe I am, the code looks like this:

  connection.setAutoCommit(false);
  insert = connection.prepareStatement(
             "INSERT INTO FOO (A, B) VALUES (?, ?)");
  insert.setString(1, somestring);
  insert.setBytes(2, byte[] xx);
  insert.executeUpdate();
  connection.commit();
  connection.setAutoCommit(true);

The exception gets thrown out of setBytes, at the point where the
driver tries to close the stream that copied the bytes into the LOB,
and long before the SQL statement actually gets executed.

[Note that this is neither the first nor the last statement on that
connection, since connections get pooled by the app server; could
this be causing the problem?]

Thanks,

--dv

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


pgsql-jdbc by date:

Previous
From: "Dave Cramer"
Date:
Subject: RE: [PATCH] setTimestamp(int, Timestamp) fails on null timestamp
Next
From: Barry Lind
Date:
Subject: Re: : SQLException.getErrorCode() : Where can I find list of error code and description ?