Re: Passing arrays

From: Kris Jurka <books(at)ejurka(dot)com>
To: Konrad Machlowski <travikkman(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Passing arrays
Date: 2008-07-29 04:10:38
Message-ID: Pine.BSO.4.64.0807241406130.32635@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Thu, 24 Jul 2008, Konrad Machlowski wrote:

> I've been looking for a way to pass from Java an array value (
> Object[]/Integer[]/String[]/... ) to postgresql int2[]/varchar[] stored
> function.

You need to call setArray on a PreparedStatement or CallableStatement.
This takes java.sql.Array instead of Integer[]. You can create a
java.sql.Array easily if you're using a recent JDBC4 driver via
Connection.createArrayOf. If it's an older driver than you must create
a class that implementes java.sql.Array yourself.

Kris Jurka

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2008-07-29 04:17:26 Re: numeric type
Previous Message Kris Jurka 2008-07-29 04:08:34 Re: implementing binary datatransfers in pg jdbc