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 69C928B9E30 for ; Tue, 22 Feb 2005 21:44:26 +0000 (GMT) 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 23548-06 for ; Tue, 22 Feb 2005 21:44:21 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 4844C8B9E57 for ; Tue, 22 Feb 2005 21:44:22 +0000 (GMT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1D3hpJ-0004Ue-00; Wed, 23 Feb 2005 10:44:17 +1300 Message-ID: <421BA7AF.8030709@opencloud.com> Date: Wed, 23 Feb 2005 10:44:15 +1300 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0 (X11/20041228) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Greg Johnson Cc: pgsql-jdbc@postgresql.org Subject: Re: Multi-Demensional Array Support. References: <1109094217.6541.24.camel@watto.interprose.net> In-Reply-To: <1109094217.6541.24.camel@watto.interprose.net> X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200502/160 X-Sequence-Number: 12340 Greg Johnson wrote: > I started hacking in multi-dimensional array support into the driver. > > However, with the getArray() function I have to return an ArrayList of > ArrayLists (or Object[] of Object[]) instead of the native type Object > [][] for example. I was wondering what you guys/gals thoughts are on the > this? > > As an application developer I personally would like to get ArrayLists of > ArrayLists back. I assume you mean java.sql.Array.getArray(). The javadoc says you have to return a real array, not an ArrayList. I think it makes sense to return a multidimensional array when you have a multidimensional array on the server side; why would you want to require the extra casting on element access that you'd need if you returned an Object[] containing Object[] elements? (are there any other JDBC drivers that support multidimensional arrays? what do they do here?) > It seems that unless you what to have a whole bunch of nasty "if" logic > that is the only way to implement multi-dimensional arrays cleanly. > Example: > if array_dims==1 > returnVal = String[]; > if array_dims==2 > returnVal = String[][]; > else if array_dims==3 > returnVal = String[][][]; > > .. but I am not java guru so if there is a better way let me know. You can build and access arrays where you don't know the component type at compile type by using the methods of java.lang.reflect.Array. > Also, is there a reason why a regular expression is not used to parse > out the array string returned from postgresql? java.util.regex is not present in JDK 1.2/1.3, which the driver needs to compile under. -O