Re: Re: Not able to insert array of integers into column of type integer array

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: pprotim <pprotim80(at)yahoo(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Re: Not able to insert array of integers into column of type integer array
Date: 2012-10-02 01:33:24
Message-ID: 506A4464.6090602@ringerc.id.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

pprotim: It looks like you tried to reply here, but just posted the
quoted original message.

I've been looking at the JDBC standard to see if PgJDBC can legally
accept arrays of primitive types and strings, not just java.sql.Array .
While this is something that the standard does not require it seems to
be something people expect the driver to do, and something other drivers do.

If you work with and have tested with other drivers it'd be helpful to
know how they behave for as many different drivers as you have access to.

--
Craig Ringer

On 10/02/2012 12:08 AM, pprotim wrote:
>
> ------------------------------------------------------------------------
> *From:* Stefan Reiser [via PostgreSQL] <[hidden email]>
> *To:* pprotim <[hidden email]>
> *Sent:* Wednesday, September 26, 2012 9:40 PM
> *Subject:* Re: Not able to insert array of integers into column of type
> integer array
>
> When setting or updating arrays in a ResultSet or PreparedStatement you
> can't use java array types (Integer[], ...) -- they need to be wrapped
> in a "java.sql.Array". This is done using the Connection-object.
>
> here's an example with Floats:
>
> Connection con = // your connection
> Double[] dbArr = // ... some java array
> Array sqlArray = con.createArrayOf("float8", dbArr);
>
> Now "sqlArray" can be used with setArray() (or even setObject() ).
> (not sure where, but there were some other examples in the JDK-docs or
> pg-JDBC-docs ...)

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Craig Ringer 2012-10-02 03:56:10 Re: data set combination of integer and decimal/numeric returns wrong result type
Previous Message the6campbells 2012-10-01 17:47:56 Re: data set combination of integer and decimal/numeric returns wrong result type