passing array as parameters to PrepareStatement or callable statement.[setObject() or setArray()] - Mailing list pgsql-jdbc

From Assad Jarrahian
Subject passing array as parameters to PrepareStatement or callable statement.[setObject() or setArray()]
Date
Msg-id 4bd3e1480511120921y6359a0achab46a321b4802219@mail.gmail.com
Whole thread Raw
Responses Re: passing array as parameters to PrepareStatement or callable
List pgsql-jdbc
Hello all,
  my apologies if this question has been asked before. I looked
through the archives could not find the relevant info (if I overlooked
something, sorry).



int[] intarray = new int[1];
getAssociatedLMs.setObject(1, intarray, java.sql.Types.ARRAY);
//getAssociatedLM's is a callable statement ("{call getLMs(?,?) } ");

so I get a compilation error saying
org.postgresql.util.PSQLException: Cannot cast an instance of [I to
type Types.ARRAY
    at org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:1637)
    at org.postgresql.jdbc3.AbstractJdbc3Statement.setObject(AbstractJdbc3Statement.java:1435)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:1652)
    at    //the setObjectLineAbove


IF I change it to type Integer[]
org.postgresql.util.PSQLException: Cannot cast an instance of
[Ljava.lang.Integer; to type Types.ARRAY
    at org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:1637)
......


I notice  Dave Cramer mentioned something about this could be an
easier process. But what is the process now? (aka, am I completely
off?)
Much thanks in advance.

Assad

pgsql-jdbc by date:

Previous
From: kevin@mtel.co.uk
Date:
Subject: Re: strange jdbc problem moving to 8.1 database
Next
From: Joost Kraaijeveld
Date:
Subject: prepareThreshold=1 and statement.executeBatch() ??