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: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
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  

But, when I call:

Integer[] values = MyClass.<Integer>getArray(rs,  
( "myIntegerArrayColumn" is of type integer[])

I get a:
java.lang.ClassCastException: [I

Any ideas?



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-2017 The PostgreSQL Global Development Group