X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.192]) by svr1.postgresql.org (Postfix) with ESMTP id B90ACCD247 for ; Sun, 20 Jul 2003 16:38:15 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr4.postgresql.org [64.117.224.192]) (amavisd-new, port 10024) with ESMTP id 12021-03 for ; Sun, 20 Jul 2003 16:38:53 +0000 (GMT) Received: from exchange.hq.openratings.com (unknown [141.149.165.226]) by svr1.postgresql.org (Postfix) with ESMTP id 45628CD254 for ; Sun, 20 Jul 2003 13:38:14 -0300 (ADT) Received: from openratings.com (dsl092-073-052.bos1.dsl.speakeasy.net [66.92.73.52]) by exchange.hq.openratings.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id 38QMV3DH; Sun, 20 Jul 2003 12:38:52 -0400 Message-ID: <3F1AC5D1.4010307@openratings.com> Date: Sun, 20 Jul 2003 12:39:45 -0400 From: Dima Tkach User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Oliver Jowett Cc: Kim Ho , Fernando Nasser , Barry Lind , pgsql-jdbc-list , Dave Cramer Subject: Re: Prepared Statements References: <3F1801C5.9030104@openratings.com> <3F181A81.70208@xythos.com> <3F18259C.6090503@redhat.com> <1058548037.19658.159.camel@topanga.toronto.redhat.com> <3F183004.4010508@openratings.com> <3F1830F6.3020203@openratings.com> <1058550328.19657.168.camel@topanga.toronto.redhat.com> <3F183423.9030900@openratings.com> <1058551402.20165.177.camel@topanga.toronto.redhat.com> <3F183AE0.8060204@openratings.com> <20030719012555.GA20158@opencloud.com> In-Reply-To: <20030719012555.GA20158@opencloud.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/185 X-Sequence-Number: 7569 The problem with this (and other similar suggestions in this thread - like use PGArray etc.) is that the app will not even compile with postgres jdbc classes. The whole point in using jdbc interfaces is to abstract the application from the particular driver implementation. The way it works currently, it is entirely possible either (text representation of arrays vary between vendors, as do ways you can use to specify sets as parameters), but, at least, you don't have to maintain the whole special piece of code, that can only compile when postgres driver is available. Dima Oliver Jowett wrote: >On Fri, Jul 18, 2003 at 02:22:24PM -0400, Dmitry Tkach wrote: > > > >>What I am concerned about is the "in" thing - >> >>select * from sometable where x in ?; >>setObject (1, "(1,2,3,4,5)"); >> >>that works just fine right now, and will be irreperably broken by this >>patch... >> >> > >How about: > > + create an org.postgresql.InSet class that wraps an Object[] array and java.sql.Types value > + use setObject(N, new InSet(myArray, Types.INTEGER)); > >The Javadoc for PreparedStatement.setObject() says: > > Note that this method may be used to pass datatabase- specific abstract data > types, by using a driver-specific Java type. > >so presumably this is the right way to do it. setObject() would handle an >InSet by individually escaping the components of the array it wraps as if >they had been passed to setObject() and turning them into an IN-like clause. > >For arrays we just need to fix setArray() so that it does the same sort of >thing as described above, using the java.sql.Array methods to get the >component objects. And maybe provide a simple implementation of Array that >wraps a Java array (users can always provide their own, anyway). > >Any thoughts? I can try to sort out patches, but I'm a bit short on time >right now so no promises. > >-O > >