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 3EEBFD1B1A0 for ; Fri, 18 Jun 2004 20:05:58 -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 53594-09 for ; Fri, 18 Jun 2004 23:05:56 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 81BB2D1B193 for ; Fri, 18 Jun 2004 20:05:52 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=opencloud.com) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1BbSQb-0005Em-00; Sat, 19 Jun 2004 11:05:45 +1200 Message-ID: <40D37597.9030705@opencloud.com> Date: Sat, 19 Jun 2004 11:07:03 +1200 From: Oliver Jowett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jie Liang Cc: Kris Jurka , pgsql-jdbc@postgresql.org Subject: Re: Prepare Statement References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200406/104 X-Sequence-Number: 10306 Jie Liang wrote: > So, I think that PreparedStatement should have a way at least case a > String to an Array or a way to create a Array, because of > conn.prepareStatement("SELECT myfunction('{1,2,3}')") is NOT very > useful. One way that might work in the current driver is to use PGobject, which lets you specify the underlying typename to use: stmt = conn.preparedStatement("SELECT myfunction(?)"); org.postgresql.util.PGobject obj = new PGobject(); obj.setValue("'{1,2,3}'"); obj.setType("int[]"); stmt.setObject(1, obj); Untested, but in theory this should work even with setUseServerPrepare(true) in effect. Also, if you search the archives, quite some time ago (a year?) I posted a patch that implemented setArray() better, so that you could pass your own Array implementation to it and have things work correctly. It's out of date, but might give you a starting point. -O