Monday, July 28, 2008

Re: [JDBC] Passing arrays

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


--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

No comments: