From: | Kris Jurka <books(at)ejurka(dot)com> |
---|---|
To: | Thomas O'Dowd <tom(at)uwillsee(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Array support |
Date: | 2005-04-21 18:41:17 |
Message-ID: | Pine.BSO.4.56.0504211333040.5816@leary.csoft.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Oliver Siegmar | 2005-04-21 19:37:23 | Re: Interval support for Postgres |
Previous Message | Kris Jurka | 2005-04-21 18:32:11 | Re: Interval support for Postgres |