pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Thomas O'Dowd <tom@uwillsee.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Array support
Date: Thu, 21 Apr 2005 13:41:17 -0500 (EST)
Message-ID: <Pine.BSO.4.56.0504211333040.5816@leary.csoft.net> (raw)
In-Reply-To: <1114094185.26958.22.camel@localhost.localdomain>
References: <1114094185.26958.22.camel@localhost.localdomain>



On Thu, 21 Apr 2005, Thomas O'Dowd wrote:

> [ I want to use setObject(1, new String[] {"a","b"}) ]
> 
> According to the JDBC Spec, jdbc-3_0-fr-spec.pdf, the recommended way to
> set an array is by using the ps.setObject() method. Is this easy to
> implement? If someone can point me at some code, I can try implementing
> it and sending in a patch.

The difficulty is the code to do things like turn java types into their pg 
representation doesn't really have a callable interface, it's all spread 
out and embedded all over the place.  Creating another copy would kind 
of suck.  As I see it this work is kind of lumped into a general task of 
moving datatype read/write methods into accessible places that could be 
used by other new things, for example COPY and binary parameter 
send/receive.

> Should be possible to make it support multiple dimension arrays too I
> guess. I haven't actually looked at the driver code yet. Oh I haven't
> gotten around to testing ResultSet.getArray() yet, but I think I
> remember reading somewhere that it was implemented.

getArray() will return java.sql.Array which probably isn't what you'd 
expect.  getObject() should also return java.sql.Array, so there will 
likely be some disconnect here.

> PS. I looked at trying to use PreparedStatement.setArray() but it takes
> an java.sql.Array, which is just an Interface. I guess I could try
> creating a class that implements Array and try passing that to
> setArray() but I'm not even sure if that would work yet either. The
> setObject() way suggested by the spec is definitely simpler.

That will work although there are some requirements for getBaseTypeName I 
think, it must return the pg specific type name used.

Kris Jurka



view thread (7+ messages)  latest in thread

Message-ID: <Pine.BSO.4.56.0504211333040.5816@leary.csoft.net>
Permalink:  ../Pine.BSO.4.56.0504211333040.5816@leary.csoft.net/
Also on:    postgresql.org/message-id/Pine.BSO.4.56.0504211333040.5816@leary.csoft.net

 · 

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 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: books@ejurka.com, tom@uwillsee.com
  Subject: Re: Array support
  In-Reply-To: <Pine.BSO.4.56.0504211333040.5816@leary.csoft.net>
  References: <1114094185.26958.22.camel@localhost.localdomain> <Pine.BSO.4.56.0504211333040.5816@leary.csoft.net>

* 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