[JDBC] Re: JDBC and the hstore ? operator - no longer working with build1211 - Mailing list pgsql-jdbc

From Thomas Kellerer
Subject [JDBC] Re: JDBC and the hstore ? operator - no longer working with build1211
Date
Msg-id o9j3h7$ghu$1@blaine.gmane.org
Whole thread Raw
In response to Re: [JDBC] Re: JDBC and the hstore ? operator - no longer workingwith build 1211  (Mark Rotteveel <mark@lawinegevaar.nl>)
List pgsql-jdbc
Mark Rotteveel schrieb am 02.03.2017 um 19:10:
>>    connection.prepareStatement("select * from foo where hstore_column ?& array['key']");
>>    connection.prepareStatement("select * from foo where hstore_column ?| array['key']");
>>
>> The prepareStatement() call succeeds, but when calling executeQuery()
>> an exception is thrown:
>>
>>    org.postgresql.util.PSQLException: No value specified for parameter 1.
>>
>> The goal is to pass the array as a parameter, something like:
>>
>>    Array keys = con.createArrayOf("text", new String[] {"key1","key2"});
>>    connection.prepareStatement("select * from foo where hstore_column ?& ?");
>>    pstmt.setArray(1, keys);
>>    ResultSet rs = pstmt.executeQuery();
>>
>> Tested with 1212 and 42.0.0
>
> I haven't tried it, but would you logically need to use ??& and ??|, if the ? operator is escaped using ??

That indeed does work.

We first tried it with an obfuscation layer (aka "ORM") which seems to mess around with those operators and breaks that
escaping.

Thomas



pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: Problem updating driver to 42.0.0
Next
From: Bogdan Daniliuc
Date:
Subject: Re: Problem updating driver to 42.0.0