Advice fetching Array data with JDBC 8.3 driver

From: "Woody Woodring" <george(dot)woodring(at)iglass(dot)net>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Advice fetching Array data with JDBC 8.3 driver
Date: 2008-03-26 12:53:32
Message-ID: 06a801c88f40$6593e7d0$80b1a8c0@istructure.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Upgrading to the latest 8.3 JDBC driver broke one of our queries (that we
have found) that involves arrays in the database. Reverting to the latest
8.2 driver fixes it.

The table is:

Table "public.cpe_health"
Column | Type | Modifiers
--------------+------------+------------------------------------------------
-------------------
cpe_healthid | integer | not null default
nextval('cpe_health_cpe_healthid_seq'::regclass)
mac | macaddr |
polldate | integer |
health | smallint |
data | integer[] |
alarm | smallint[] |

My query is:

SELECT mac, CASE health WHEN 0 THEN 'red' WHEN 1 THEN 'yellow' WHEN 3 THEN
'green' ELSE 'blue' END AS health,
array_upper(data,1) AS datasize, data, alarm
FROM cpe_health;

The exception I get is:

java.lang.ClassCastException: [Ljava.lang.Integer;
at
net.iglass.jglass.cpe.dao.CpeDataDAO$14.handle(CpeDataDAO.java:1018)
at net.iglass.db.QueryRunner.query(QueryRunner.java:315)
at net.iglass.db.QueryRunner.query(QueryRunner.java:336)
at
net.iglass.jglass.cpe.dao.CpeDataDAO.getHealthData(CpeDataDAO.java:1042)

Which line 1018 in my code is:
int[] hdata = (int[])(rs.getArray("data")).getArray();

Any advice on how to properly fetch the array data in my code would be
appreciated.

Thanks
Woody

----------------------------------------
iGLASS Networks
3300 Green Level Rd. West
Cary NC 27519
(919) 387-3550 x813
www.iglass.net

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Mark Lewis 2008-03-26 15:15:54 Re: Non-ORM layers over JDBC
Previous Message Tore Halset 2008-03-26 10:21:45 Re: Non-ORM layers over JDBC