Thread: lo_tell problem with JDBC and RC4

lo_tell problem with JDBC and RC4

From
Elijah Roberts
Date:
I'm having a problem with JDBC and large objects. I'm using 7.0RC4 and JDBC
2. I have a table like the following:

CREATE TABLE document_Page
(
    ...
    data    OID    NULL
    ...
);

I insert using the JDBC PreparedStatement.setBytes(1, data), and it works.
I have exported the object using the \lo_export command in psql and it
comes out ok. When I try to select the data through JDBC, though, I have
problems.

If I use the following code, I simply get the object ID, such as 280065,
which is understandable:

    st = db.prepareStatement("SELECT data FROM document_page");
    rs = st.executeQuery();
    if (rs.next()) rs.getString(1);

However, if I use the following line instead, to try to get the data:

    if (rs.next()) rs.getBytes(1);

I get the following exception:

    FastPath call returned ERROR: lo_tell: invalid large object descriptor (0)
at         org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:141)
        at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:191)
        at org.postgresql.fastpath.Fastpath.getInteger(Fastpath.java:203)
        at org.postgresql.largeobject.LargeObject.tell(LargeObject.java:232)
        at org.postgresql.largeobject.LargeObject.size(LargeObject.java:247)
        at org.postgresql.jdbc2.ResultSet.getBytes(ResultSet.java:370)

It seems to me it may be trying to use 0 as the oid [object descriptor (0)
at], but I don't know if that's accurate. It seems like it should be able
to get the correct oid, as it prints it out fine when I use getString to
retrieve the result.

Any thought? BTW, I'm running the server on Solaris and the client on
WindowsNT with Sun's JDK 1.3 RC2.

Elijah Roberts
Java Consultant
eroberts@alexandriasc.com
606-816-1186