Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 8681B9FA410 for ; Fri, 2 Feb 2007 05:32:03 -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 38897-05 for ; Fri, 2 Feb 2007 05:32:00 -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 EB4DC9FA30D for ; Fri, 2 Feb 2007 05:31:59 -0400 (AST) Received: (qmail 19347 invoked from network); 2 Feb 2007 10:31:57 +0100 Received: from 89-24-5-99.customers.t-mobile.cz (HELO ?172.24.108.150?) (miroslav.sulc@startnet.cz@89.24.5.99) by titan.local.startnet.cz with ESMTPA; 2 Feb 2007 10:31:57 +0100 Message-ID: <45C304FB.6020702@startnet.cz> Date: Fri, 02 Feb 2007 10:31:39 +0100 From: =?ISO-8859-2?Q?Miroslav_=A9ulc?= 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: JDBC and arrays References: <45C295F4.4030100@startnet.cz> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.687 tagged_above=0 required=5 tests=AWL, BAYES_40 X-Spam-Level: X-Archive-Number: 200702/14 X-Sequence-Number: 16570 Thank you for explanation. If I still want to write inet[] data, is it sufficient to implement PGobject so it returns 'inet[]' type and '{ "ip", "ip" }' value and pass that to setObject()? -- Miroslav Šulc Kris Jurka napsal(a): > > > On Fri, 2 Feb 2007, Miroslav Šulc wrote: > >> I tried to find some info on how to work with arrays using PostgreSQL >> JDBC driver but didn't find anything useful except that I can >> implement java.sql.Array to get support for arrays. Can someone, >> please, send me a link on how to write and read array data using >> PostgreSQL JDBC driver or give me a brief explanation? I'm also >> interested how to work with inet[] arrays as they do not seem to be >> directly supported by JDBC API. > > Reading arrays is pretty straightforward: > > ResultSet rs = stmt.executeQuery("SELECT '{a,b}'::text[]"); > rs.next(); > Array arr = rs.getArray(1); > String s[] = (String)arr.getArray(); > > Writing arrays is not easy because prior to the JDBC4 spec there was > no way to create java.sql.Array objects without creating a class that > implements java.sql.Array yourself. Now JDBC4 offers > Connection.createArrayOf() which unfortunately we haven't implemented > yet. So while there is a light at the end of the tunnel you're still > stuck implementing java.sql.Array yourself. Check the mailing list > for examples of that. > > Currently arrays of non-standard datatypes like inet are not > supported. Seems possible to do if you were willing to use PGobject > for unknown types, but no one has done it. > > Also more complicated things like multi-dimensional arrays are note > supported. > > Kris Jurka > ---------------------------(end of broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org