From: Craig Ringer <ringerc@ringerc.id.au>
To: pprotim <pprotim80@yahoo.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Re: Not able to insert array of integers into column of type integer array
Date: Tue, 02 Oct 2012 09:33:24 +0800
Message-ID: <506A4464.6090602@ringerc.id.au> (raw)
In-Reply-To: <1349107725.96229.YahooMailNeo@web120301.mail.ne1.yahoo.com>
References: <1348674063961-5725537.post@n5.nabble.com>
<506328AC.2070206@tu-braunschweig.de>
<1349107725.96229.YahooMailNeo@web120301.mail.ne1.yahoo.com>
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 ...)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: ringerc@ringerc.id.au, pprotim80@yahoo.com
Subject: Re: Not able to insert array of integers into column of type integer array
In-Reply-To: <506A4464.6090602@ringerc.id.au>
References: <1348674063961-5725537.post@n5.nabble.com> <506328AC.2070206@tu-braunschweig.de> <1349107725.96229.YahooMailNeo@web120301.mail.ne1.yahoo.com> <506A4464.6090602@ringerc.id.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox