Re: Retrieving arrays

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Markus Schaber <schabi(at)logix-tt(dot)com>
Cc: Bendik Rognlien Johansen <bensmailinglists(at)gmail(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Retrieving arrays
Date: 2006-10-11 16:32:49
Message-ID: 5185E6C8-4198-4A67-8410-D71762E061A1@fastcrypt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


On 11-Oct-06, at 9:43 AM, Markus Schaber wrote:

> Hi, Bendik,
>
> Bendik Rognlien Johansen wrote:
>
>> yes you are right, I don't really understand Generics that well.
>> But it
>> is a little clearer now :-)
>>
>> Anyway, I was hoping there would be a clean way to get arrays from
>> the
>> result set, Generics or not, using a single method. I would like
>> to avoid:
>> getStringArray, getIntegerArray etc.
>
> Usually, ResultSet.getArray() should do it.
>
>> The reason I need to do this is that I use two different drivers for
>> PostgreSQL with the same code, and they handle arrays differently.
>
> So you say that the the other one (pljava, IIRC) maps a postgresql
> integer[] to an java.lang.Integer[] in java, and not an int[] like
> pgjdbc?
>
> Looks strange.
>
> Does the jdbc spec promote one or the other behaviour?
Yes, the spec, and the desire to not create a huge number of objects
does promote one method over another

pp 285 from JDBC API Tutorial and Reference 3rd Edition states

"The data type for the elements is determined by the standard mapping
from JDBC Types to Objects ... There is one very important exception
to this rule. If the base type of the array maps to a primitive type
in the Java programming language, the base type of the returned array
will be the primitive type rather than the Object type"

So I'd suggest you file a bug with pl/java

Dave
>
> However, I don't know a clean solution.
>
> Markus
> --
> Markus Schaber | Logical Tracking&Tracing International AG
> Dipl. Inf. | Software Development GIS
>
> Fight against software patents in Europe! www.ffii.org
> www.nosoftwarepatents.org
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Michael Goldner 2006-10-11 17:14:59 "Hanging Connection" blocks access to table (JBossMQ)
Previous Message Markus Schaber 2006-10-11 13:43:09 Re: Retrieving arrays