From: Ulrich Meis <kenobi@halifax.rwth-aachen.de>
To: jessica xingzc_he <xingzc_he@hotmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: persistence of java objects
Date: Sun, 31 Oct 2004 21:29:57 +0100
Message-ID: <200410312129.57710.kenobi@halifax.rwth-aachen.de> (raw)
In-Reply-To: <BAY24-F1bpH71yEXUIE00031b91@hotmail.com>
References: <BAY24-F1bpH71yEXUIE00031b91@hotmail.com>
On Sunday 31 October 2004 01:05, jessica xingzc_he wrote:
> hi,
>
> Does postgresql support this? if i want a column of a table for the
> persistence of instance of java objects, and use ResultSet.getObject() and
> ResultSet.updateObjecct() to access them. if so, what data type the column
> should be?
If you use a standard type like integer or varchar, you can do things like
setObject(1,new Integer(5));
setObject(2,"something");
which would be equivalent to
setInteger(1,new Integer(5));
setString(2,"something");
If you want to store complex objects in the database then they should
implement the java.io.serializable interface. Thereby you can store them in a
byteArray or push them into a bytearraystream and write the result with the
usual methods into the database.
A simple serialization example is here for java.io.File:
http://java.sun.com/j2se/1.3/docs/guide/serialization/spec/examples.doc1.html
Regards,
Uli
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: kenobi@halifax.rwth-aachen.de, xingzc_he@hotmail.com
Subject: Re: persistence of java objects
In-Reply-To: <200410312129.57710.kenobi@halifax.rwth-aachen.de>
References: <BAY24-F1bpH71yEXUIE00031b91@hotmail.com> <200410312129.57710.kenobi@halifax.rwth-aachen.de>
* 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