Re: JDBC question: Creating new arrays - Mailing list pgsql-general

From Doug McNaught
Subject Re: JDBC question: Creating new arrays
Date
Msg-id m3y97yqmcv.fsf@varsoon.wireboard.com
Whole thread Raw
In response to JDBC question: Creating new arrays  (Joe Tomcat <tomcat@mobile.mp>)
Responses Solved, and a bug found! Re: JDBC question: Creating new arrays  (Joe Tomcat <tomcat@mobile.mp>)
List pgsql-general
Joe Tomcat <tomcat@mobile.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

pgsql-general by date:

Previous
From: Joe Tomcat
Date:
Subject: JDBC question: Creating new arrays
Next
From: Neil Conway
Date:
Subject: Re: Upgrade to dual processor machine?