Thread: About Postgres Large Object

About Postgres Large Object

From
root
Date:
Hi ,
I am using postgresql 7.1.3 and Redhat 7.3
I am running this servlet given below.  But it is not running

//Retrieving the image from the database:
 // All LargeObject API calls must be within a transaction
 con.setAutoCommit(false);

 // Get the Large Object Manager to perform operations with
 LargeObjectManager lobj =
    ((org.postgresql.Connection)con).getLargeObjectAPI();

 PreparedStatement pstmt =
    con.prepareStatement("SELECT img FROM images WHERE imgname=?");
 pstmt.setString(1, "myimage.gif");
 ResultSet rs = pstmt.executeQuery();

 if (rs != null) {
    while(rs.next()) {
       // open the large object for reading
       int oid = rs.getInt(1);
       LargeObject obj = lobj.open(oid, LargeObjectManager.READ);

       // read the data
       byte buf[] = new byte[obj.size()];
       obj.read(buf, 0, obj.size());

       // do something with the data read here

       // Close the object
       obj.close();
    }
    rs.close();
 }
 pstmt.close();



Error  message is given below



[27/01/2004 10:19:43:138 IST] java.lang.NoSuchMethodError:
org.postgresql.largeo
bject.LargeObject.read([BII)V
        at
org.apache.jserv.JServConnection.processRequest(JServConnection.java:
323)
        at
org.apache.jserv.JServConnection.run(JServConnection.java:188)
        at java.lang.Thread.run(Thread.java:536)


Re: About Postgres Large Object

From
Kris Jurka
Date:

On Tue, 27 Jan 2004, root wrote:

> Hi ,
> I am using postgresql 7.1.3 and Redhat 7.3
> I am running this servlet given below.  But it is not running
>
>        obj.read(buf, 0, obj.size());
>
> [27/01/2004 10:19:43:138 IST] java.lang.NoSuchMethodError:
> org.postgresql.largeo
> bject.LargeObject.read([BII)V

I wonder if you are running your application with the same
version you compiled against.  I note the cvs log shows:

revision 1.2
date: 2001/01/31 08:26:02;  author: peter;  state: Exp;  lines: +29 -23
        - Changed LargeObject.read(byte[],int,int) to return the actual
number of bytes read (used to be void).

This was between the 7.0 and 7.1 release.  So I'm guessing you have a
mismatch between compilation and runtime jar files.  That said I'm
obligated to remind you that 7.1 is old you should upgrade.

Kris Jurka