Thread: Passing arrays

Passing arrays

From
"Konrad Machlowski"
Date:
Hello.
 
I've been looking for a way to pass from Java an array value ( Object[]/Integer[]/String[]/... ) to postgresql int2[]/varchar[] stored function.
Can somebody point me to anything, please?

--
Regards,
TrAvIkK

Re: Passing arrays

From
Kris Jurka
Date:

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