PreparedStatment.setBinaryStream() - Mailing list pgsql-jdbc

From Brian Jordan
Subject PreparedStatment.setBinaryStream()
Date
Msg-id OLEMLCFKHJJDEPCKDOANEEHNCBAA.bjordan@ie3ventures.com
Whole thread Raw
Responses Re: PreparedStatment.setBinaryStream()  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-jdbc
I was wondering if anyone had any insight to a problem I am having with the
setBinaryStream() function call.  I am using Postgresql 7.1.1 running under
Win 2000 via the Cygnus environment.  The JDBC driver is also version 7.1.1
(Enterprise) successfully compiled from the latest source available via
postgresql.org.  I am using JDK 1.3.1.

I am attempting to place binary data into the database to include images and
serialized data.  I ran through the image and blob tests in the "example"
package for the driver and was able to successfully insert and remove images
and blobs from the database.   However, I am unable to insert binary data
into the database via the setBinaryStream() function.  I am required to use
this method because a third-party component uses this method and I have no
way to alter the code.

I have traced the problem through to the
org.postgresql.fastpath.Fastpath.fastpath() method.  When the stream that is
created in PreparedStatement.setBinaryStream() is closed, the

fastpath(int fnid,boolean resulttype,FastpathArg[] args)

method gets called to execute the lo_write function that writes the data
into the database of the pg_largeobject table and write the OID into my
table as a pointer to the data.  When this occurs, the backend returns 69 to
indicate an error and the fastpath() method throws an exception --

    // Error message returned
    case 'E':
      throw new
PSQLException("postgresql.fp.error",stream.ReceiveString(4096));

The debug output from the console where Postgresql is running displays the
following:

    lo_write: invalid large object descriptor (0)

Is there something that I am missing here or is this a bug?  Really
appreciate any thoughts on what is causing the problem and how to correct
it.

Finally, does anyone know where I can pull down the very latest version of
the patched source code?  I see references in the discussion to patches
being applied and wanted to make sure that I had them to update the source
or get the latest patched source.

Thanks

Brian Jordan

Attachment

pgsql-jdbc by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Patches for Serialize.java
Next
From: Bruce Momjian
Date:
Subject: Re: PreparedStatment.setBinaryStream()