Re: JDBC question: Creating new arrays

From: Doug McNaught <doug(at)mcnaught(dot)org>
To: Joe Tomcat <tomcat(at)mobile(dot)mp>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: JDBC question: Creating new arrays
Date: 2002-11-13 01:39:28
Message-ID: m3y97yqmcv.fsf@varsoon.wireboard.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Joe Tomcat <tomcat(at)mobile(dot)mp> writes:

> It seems that there is a difficulty in JDBC with creating arrays. I
> have an array of ints that I want to store in PG. If I try code like
> this:
>
> int[] intArray = { .... };
> PreparedStatement ps = db.prepareStatement(...);
> ps.setObject(1, intArray);
>
> it doesn't work. There is a PreparedStatement.setArray() method, but it
> takes a java.sql.Array as an argument, and yet the Array interface
> doesn't define any constructors and there doesn't seem to be any factory
> for it either!!!!

Then you probably need to wrap your Java array in an object that
implements java.sql.Array so that the JDBC driver can talk to it.
Shouldn't be hard.

-Doug

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Neil Conway 2002-11-13 03:37:35 Re: Upgrade to dual processor machine?
Previous Message Bruno Wolff III 2002-11-13 01:08:55 Re: Time manipulation..