Skip site navigation (1) Skip section navigation (2)

Retrieving arrays

From: Bendik Rognlien Johansen <bensmailinglists(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Retrieving arrays
Date: 2006-10-10 13:15:23
Message-ID: 533747B3-BC3C-4D07-A2B8-A3C86B85C718@gmail.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
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

Responses

pgsql-jdbc by date

Next:From: Heikki LinnakangasDate: 2006-10-10 14:02:52
Subject: Re: Postgres XA support
Previous:From: Per JensenDate: 2006-10-10 12:05:02
Subject: Re: Test of 8.2beta1 fails

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group