this will store/retrieve your objects to a binary attribute in a relational
table
private byte[] serialize(Object obj) throws IOException {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(byteStream);
oos.writeObject(obj);
return byteStream.toByteArray();
}
private Object deserialize(byte[] byteArray)
throws IOException, ClassNotFoundException {
if (byteArray == null)
return null;
else {
ByteArrayInputStream byteStream = new
ByteArrayInputStream(byteArray);
ObjectInputStream ois = new ObjectInputStream(byteStream);
return ois.readObject();
}
}
> -----Original Message-----
> From: Jay Baker [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, August 31, 1999 3:11 PM
> To: [EMAIL PROTECTED]
> Subject: Serializing your objects
>
> This may be a bit off topic - apologies. I don't normally subscribe to
> generic java lists though.
>
> I'm looking for suggestions on Serializing your objects. I want to store
> my objects in a database for the purpose of persistence. In other words,
> I'm not just looking at storing some data in the database that the objects
> use. My only interest in having these objects interact with the DB in any
> other way than normal is for the purposes of preserving their state. I'm
> sure there is much material on this. I'm looking for some suggestions and
> pointers in the right direction.
>
> Thanks.
>
> Jay Baker
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".