Re: Retrieving arrays - Mailing list pgsql-jdbc

From Mark Lewis
Subject Re: Retrieving arrays
Date
Msg-id 1160503178.8082.10.camel@archimedes
Whole thread Raw
In response to Retrieving arrays  (Bendik Rognlien Johansen <bensmailinglists@gmail.com>)
Responses Re: Retrieving arrays  (Bendik Rognlien Johansen <bensmailinglists@gmail.com>)
List pgsql-jdbc
Java 5 doesn't support auto-boxing an int[] as an Integer[].

-- Mark Lewis

On Tue, 2006-10-10 at 15:15 +0200, Bendik Rognlien Johansen wrote:
> Hello,
> I wrote this method to read arrays from my result set.
>
>
> public class MyClass {
>    public <T> T[] getArray(ResultSet rs, String column) throws
> Exception {
>      if(rs.getArray(column) != null) {
>        return (T[]) rs.getArray(column).getArray();
>      }
>      return null;
>    }
> }
>
>
>
> I call i like this:
>
> String[] values = MyClass.<String>getArray(rs, "myStringArrayColumn"));
>
>   This works fine. ( "myStringArrayColumn" is of type character
> varying(64)[])
>
>
> But, when I call:
>
> Integer[] values = MyClass.<Integer>getArray(rs,
> "myIntegerArrayColumn"));
> ( "myIntegerArrayColumn" is of type integer[])
>
>
> I get a:
> java.lang.ClassCastException: [I
>
>
> Any ideas?
>
> Thanks
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org

pgsql-jdbc by date:

Previous
From: "Ludovic Orban"
Date:
Subject: Re: Postgres XA support
Next
From: Bendik Rognlien Johansen
Date:
Subject: Re: Retrieving arrays