Re: [INTERFACES] storing java objects

From: Peter T Mount <peter(at)retep(dot)org(dot)uk>
To: Nathan Gelbard <gelbardn(at)intus(dot)net>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: [INTERFACES] storing java objects
Date: 1999-07-01 05:49:51
Message-ID: Pine.LNX.4.04.9907010636310.31519-100000@maidast.retep.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Wed, 30 Jun 1999, Nathan Gelbard wrote:

> Solaris 2.6, Java 1.2, postgresql 6.4.2.

First, you'll need the 6.5 driver to get it to work with JDK1.2. It will
work with 6.4.2

> I noticed getObject/setObject functions in the API, and would like to
> store java objects in my psql DB. Is this possible?

Yes.

> how do i define a table that holds java.sql.Types.JAVA.OBJECT s?

There's two methods in the API.

1. Define a class that extends postgresql.util.PGObject, then register it
with postgresql.Connection.

This allows you to implement new datatypes. Take a look at the
postgresql.geom sub-package.

2. Make any of your objects Serialisable. Then call the create() method in
postgresql.util.Serialise. This will create the necessary tables for
the object.

There's extensive notes on how to do #2 in the source to the
postgresql.util.Serialise class.

> Is there any example code laying around to do this?

I thought I did write an example, but it's not there. I'll go and look for
it.

Peter

--
Peter T Mount peter(at)retep(dot)org(dot)uk
Main Homepage: http://www.retep.org.uk
PostgreSQL JDBC Faq: http://www.retep.org.uk/postgres
Java PDF Generator: http://www.retep.org.uk/pdf

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Peter T Mount 1999-07-01 05:58:55 Re: [INTERFACES] Getting max. value size (libpq++)
Previous Message Thomas Lockhart 1999-07-01 02:48:45 Re: [INTERFACES] Reply-To: missing