pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Shevland <shevlandj@kpi.com.au>
To: pgsql-interfaces@postgresql.org
Subject: Large Object Exception/Serializing Java Objects
Date: Fri, 10 Dec 1999 11:34:43 -0800
Message-ID: <001101bf4345$9f502f60$6464a8c0@kpi.com.au> (raw)

Hi all,

I'm trying to persist some Java objects in a PostgreSQL database using JDBC
(2.0).

I get the following error:

Fri Dec 10 11:26:15 PST 1999 - [copyright] EJBoss - The EJB Open Source
Server v0.9
Fri Dec 10 11:26:48 PST 1999 - [Exception]
Fri Dec 10 11:26:48 PST 1999 - FastPath protocol error: Z
FastPath protocol error: Z
 at postgresql.fastpath.Fastpath.fastpath(Fastpath.java:159)
 at postgresql.fastpath.Fastpath.fastpath(Fastpath.java:188)
 at postgresql.fastpath.Fastpath.getInteger(Fastpath.java:200)
 at
postgresql.largeobject.LargeObjectManager.create(LargeObjectManager.java:176
)
 at
org.ejboss.storage.PGSecondaryStorage.serialize(PGSecondaryStorage.java:245)
 at org.ejboss.storage.PGSecondaryStorage.store(PGSecondaryStorage.java:117)
 at
org.ejboss.ejb.EnterpriseBeanWrapper.passivate(EnterpriseBeanWrapper.java:34
3)
 at
org.ejboss.managers.EnterpriseBeanWrapperManager$LRUThread.run(EnterpriseBea
nWrapperManager.java:403)
 at java.lang.Thread.run(Thread.java:479)

This occurs upon trying to create the large object... before going to the
source I just wanted to check that this is supposed to work and all that.

Out of interest, here's the offending code fragment (it may be just plain
wrong... any ideas appreciated!):

    private int serialize(EnterpriseBean bean)
        throws IOException, SQLException
    {
        ByteArrayOutputStream   byte_out = new ByteArrayOutputStream();
        ByteArrayInputStream    byte_in;
        ObjectOutputStream      obj_out = new ObjectOutputStream(byte_out);

        byte[]                  classbytes;
        byte                    buf[] = new byte[2048];
        int                     read=0;

        // lobj was created in the constructor...

        // Create the ejb object using the PostgreSQL specific blob support
        int oid =
lobj.create(LargeObjectManager.READ|LargeObjectManager.WRITE);

        LargeObject obj = lobj.open(oid,LargeObjectManager.WRITE);
        DriverManager.println("[PGSecondaryStorage] Got large object
obj="+obj);

        // Copy the EJB to a temporary byte array
        obj_out.writeObject( bean );
        obj_out.flush();
        classbytes = byte_out.toByteArray();
        byte_in = new ByteArrayInputStream(classbytes);

        // Copy the data to the large object
        while((read=byte_in.read(buf,0,2048))>0) {
          obj.write(buf,0,read);
        }

        obj.close();

        return oid;
    }


Thanks,
Joe.


---
Joe Shevland
Principal Consultant
KPI Logistics Pty Ltd
mailto:shevlandj@kpi.com.au
http://www.kpi.com.au




view thread (4+ messages)  latest in thread

Message-ID: <001101bf4345$9f502f60$6464a8c0@kpi.com.au>
Permalink:  ../001101bf4345$9f502f60$6464a8c0@kpi.com.au/
Also on:    postgresql.org/message-id/001101bf4345$9f502f60$6464a8c0@kpi.com.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: shevlandj@kpi.com.au
  Subject: Re: Large Object Exception/Serializing Java Objects
  In-Reply-To: <001101bf4345$9f502f60$6464a8c0@kpi.com.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox