Postgres 8.0 + JDBC

From: "Johann Robette" <jrobette(at)onyme(dot)com>
To: <pgsql-jdbc(at)postgresql(dot)org>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Postgres 8.0 + JDBC
Date: 2004-10-05 16:25:52
Message-ID: 002901c4aaf7$feabc310$a5010a0a@Johann
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc

Hello,

I have an application running under JBoss.
Up to today, I was using Postgres 7.3 and the appropriate version of the
jdbc driver.
In my application, I have to call a user-defined function which accept
in parameters 2 arrays. Here is the header of my function :
CREATE OR REPLACE FUNCTION getmembers(int8, int8, _text,
_float8)

So I called it using a prepared statement with setArray() :
double[] weights = {0.5};
String[] names = {"foo1", "foo2"};
java.sql.Array a_names = PostgresArray.create(names);
java.sql.Array a_weights = PostgresArray.create(weights);
ps = conn.prepareStatement("SELECT * FROM
getmembers(?,?,?::_text,?::_float8);");
ps.setLong(1, 1);
ps.setLong(2, 2);
ps.setArray(3, a_names);
ps.setArray(4, a_weights);
ps.executeQuery();

PostgresArray is a class which I found on the archives.postgresql.org.
The code is given is attached.

All worked fine.

But today, I decided to upgrade to Postgres 8.0 beta 3.

No problem with the definition of my function.
I downloaded the appropriate JDBC driver : pgdev.306.jdbc3.jar.

Now running the same code as before, I get the error while executing the
query :
java.sql.SQLException: ERROR: cannot cast type text to
text[]

So, what am I doing wrong?
Is it a beta bug or is my code incorrect?
What is the correct way to use SetArray()?

Thanks

JR

Attachment Content-Type Size
PostgresArray.txt text/plain 14.8 KB

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dann Corbit 2004-10-05 16:33:34 Re: Random not so random
Previous Message Reini Urban 2004-10-05 16:23:28 Re: postgresql 8.0 and tsearch2 install under cygwin

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2004-10-05 20:10:49 Re: Postgres 8.0 + JDBC
Previous Message Ahmed Mousaad 2004-10-05 15:43:00 correct installation of postgis ??