Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 833FF9FB43D for ; Sat, 17 Feb 2007 07:01:38 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 64491-01 for ; Sat, 17 Feb 2007 07:01:32 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from titan.startnet.cz (unknown [82.113.63.73]) by postgresql.org (Postfix) with ESMTP id 7F87B9FB37C for ; Sat, 17 Feb 2007 07:01:32 -0400 (AST) Received: (qmail 17458 invoked from network); 17 Feb 2007 12:01:28 +0100 Received: from 89-24-5-18.customers.t-mobile.cz (HELO ?172.24.11.215?) (miroslav.sulc@startnet.cz@89.24.5.18) by titan.local.startnet.cz with ESMTPA; 17 Feb 2007 12:01:28 +0100 Message-ID: <45D6E075.7060504@startnet.cz> Date: Sat, 17 Feb 2007 12:01:09 +0100 From: =?UTF-8?B?TWlyb3NsYXYgxaB1bGM=?= Organization: StartNet s.r.o. User-Agent: Thunderbird 1.5.0.9 (X11/20061224) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: setArray References: <20070216115103.8tagbdi2edy8g8kk@webmail.versatel.nl> In-Reply-To: <20070216115103.8tagbdi2edy8g8kk@webmail.versatel.nl> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.559 tagged_above=0 required=5 tests=BAYES_50, RCVD_IN_BL_SPAMCOP_NET X-Spam-Level: * X-Archive-Number: 200702/82 X-Sequence-Number: 16638 Hi, I recently had to solve this too. What I did is: 1) I created class that implements java.sql.Array (it is sufficient to implement getArray(), getBaseType(), getBaseTypeName() and toString(), for details see Java API docs) + I added one extra method, setArray(Class componentType, Object[] array), where componentType is component type of the array, which I use for setting the array value into the array 2) Then I use this code to set the array: final MyArray array = new MyArray(); array.setArray(componentType, arrayValue); pstm.setArray(index, array); HTH -- Miroslav Ć ulc Alex Stienstra napsal(a): > Hi, > > Iam trying to set an array in a prepared statement like this: > > PreparedStatement stmnt = ds.prepareStatement( > "INSERT INTO trainingen (\"Atleet\", \"Datum\", \"Tijdstip\", > \"Afstand\", \"Tijd (Zone)\") VALUES (?,?,?,?,?)" > ); > stmnt.setString(5, "{1,2,3,4,5,6}"); > > Assuming that the 5th parameter is an array of integer i get the > follow error message: > > ERROR: column "Tijd (Zone)" is of type integer[] but expression is of > type character varying > > I understood from previous discussions that the driver underwater will > convert the parameter of setArray > into a string representation like i do in the example above. I there > any other way of setting an array > field in a prepared statement? > > Alex. > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly