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