From: | Tiago Alves <talves(at)tapestry(dot)pt> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Using SELECT IN with prepared statement |
Date: | 2008-11-11 18:19:20 |
Message-ID: | 4919CCA8.1080609@tapestry.pt |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Thank you for all your help.
I ended implementing the interface ava.sql.Array. I just implemented the
functions getBaseType, getBaseTypeName (returning "int4"), getArray and
toString (returning a neatly formated string like "{1,2,3}").
I think that the connection.createArrayOf didn't work because it's not
implemented in the apache common-dbcp, the library I'm using.
Again, thanks!
Tiago A.
Ingmar Lötzsch escreveu:
> Hello,
>
> you can use another syntax
>
> WHERE userid = ANY (?)
>
> and call PreparedStatement.setArray(). That means, you have to provide
> an instance of java.sql.Array as parameter. For this purpose you can
> implement this interface (It's not too difficult, I've done this.) or
> use Connection.createArrayOff(). The last is available dependent on
> the JDBC-Library you use. I have not tried it yet.
>
> One advantage of ANY instead of IN is, that you can pass an empty
> array without causing a SQL syntax error.
>
> Ingmar
>
> Tiago Alves schrieb:
>> Greetings!
>>
>> Sorry if you answer this before, I couldn't find it.
>>
>> I want to do something like:
>>
>> PreparedStatement ps = connection.prepareStatement("select * from
>> users where userid in ?");
>> ps.setSomething(anIntArray);
>>
>> Is this possible? How?
>>
>> Thanks.
>> Tiago A.
>>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2008-11-11 19:26:31 | Re: Pgsql jdbc driver 8.3 Build 603: Commit deadlock |
Previous Message | Ingmar Lötzsch | 2008-11-11 16:33:29 | Re: Using SELECT IN with prepared statement |