Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JDBS setArray

2 views
Skip to first unread message

Philipp Kraus

unread,
Nov 17, 2009, 8:40:25 AM11/17/09
to
Hello,

i try to use the setArray method of postgres (8.3) JDBC driver to send
data to a function.
I hope I'm not off topic here with this problem.
In my code I have some java.lang.Double-Arrays whitch I must convert in
that way, that
I can use them in the prepare-statement context with setArray.

I found some information that I can convert the double Array to a
string list like
"..array[1,2,3,....]" but I have around 500 elements in 5 Arrays and I
would like
to send them without string reprensation

How can I do that?

Thanks

Phil

Laurenz Albe

unread,
Nov 18, 2009, 7:04:53 AM11/18/09
to
Philipp Kraus wrote:
> i try to use the setArray method of postgres (8.3) JDBC driver to send data to a function.
> I hope I'm not off topic here with this problem.

Nothing PostgreSQL-related is off-topic here, but the JDBC
mailing list has more knowledgeable people reading it.

> In my code I have some java.lang.Double-Arrays whitch I must convert in that way, that
> I can use them in the prepare-statement context with setArray.
>
> I found some information that I can convert the double Array to a string list like
> "..array[1,2,3,....]" but I have around 500 elements in 5 Arrays and I would like
> to send them without string reprensation
>
> How can I do that?

I found the following thread in the archives:
http://archives.postgresql.org/pgsql-jdbc/2008-12/msg00040.php

The two options suggested are:
- Implement the java.sql.Array interface with your types.
- Use the JDBC4 driver (requires Java 6) and use the
java.sql.Connection.createArrayOf() method.

Yours,
Laurenz Albe


Philipp Kraus

unread,
Nov 18, 2009, 8:56:01 AM11/18/09
to

In had hoped there are onther solutions. Exactly this thread
I had read before I had post. I can't use JDBC 4 because I
limited on Java 1.5 now. So I implementated the function
into the application in a transaction

Thanks

0 new messages