X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 91B825294B for ; Thu, 21 Apr 2005 15:41:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64288-03 for ; Thu, 21 Apr 2005 18:41:17 +0000 (GMT) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id 1EB6A5379E for ; Thu, 21 Apr 2005 15:41:16 -0300 (ADT) Received: (qmail 22533 invoked by uid 1112); 21 Apr 2005 18:41:17 -0000 Date: Thu, 21 Apr 2005 13:41:17 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Thomas O'Dowd Cc: pgsql-jdbc@postgresql.org Subject: Re: Array support In-Reply-To: <1114094185.26958.22.camel@localhost.localdomain> Message-ID: References: <1114094185.26958.22.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.012 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/113 X-Sequence-Number: 12720 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