serialized objects and JDBC driver - Mailing list pgsql-jdbc

From Stuart Barlow
Subject serialized objects and JDBC driver
Date
Msg-id 5.0.2.1.0.20010313144207.00a78950@192.168.0.91
Whole thread Raw
Responses Re: serialized objects and JDBC driver
List pgsql-jdbc
I am attempting to serialize objects into Postgresql using the
JDBC driver. I am attempting to do this the standard way
using Object and Byte streams.

To store the object to the database in a text (blob) field I use the
following code to turn my object into a byte[].

             // create the serialized object and store in the database
             EncryptionInfo serObj = new EncryptionInfo(32, 32);
             ByteArrayOutputStream bos = new ByteArrayOutputStream();
             ObjectOutputStream p = new ObjectOutputStream(bos);
                 p.writeObject(serObj);
                 p.flush();
             byte[] data = bos.toByteArray();


This seems to go into the database with no errors.
However when I retieeve the data using the following code...

ByteArrayInputStream bis = new ByteArrayInputStream(data);
         ObjectInputStream p = new ObjectInputStream(bis);
         EncryptionInfo ei = (EncryptionInfo)p.readObject();

I get the following error...
InputStream does not contain a serialized object


Thanks.
Stuart Barlow.

*************************************************************************
Information in this email is confidential and may be privileged. It is
intended for the named addressee(s) only. If you have received it in
error please notify the sender immediately and delete it from your
system. You should not otherwise copy, retransmit, use or disclose its
contents to anyone.
*************************************************************************


pgsql-jdbc by date:

Previous
From: Gunnar R|nning
Date:
Subject: Re: JDBC autocommit versus own commits performance
Next
From: "Dax Duskin"
Date:
Subject: Re: unset problem and installing jdbc