Fork me on GitHub
#sql
<
2022-03-25
>
skuro14:03:40

is there any way to tell java.jdbc to somehow "escape" a question mark character so that it doesn't try to treat it as a parameter substitution? My use case is the ?| JSON function in postgres:

(jdbc/query db ["select '{\"foo\": 42}'::jsonb ?| array ['foo']"])
=>
Unhandled org.postgresql.util.PSQLException
   No value specified for parameter 1.

seancorfield14:03:15

@skuro that exception is from JDBC - this is not a java.jdbc issue : it's a sql/jdbc issue in general. So the answer is "however JDBC requires that you escape a question mark"

skuro14:03:54

yep, I was actually reaching that conclusion:

(def _c (jdbc/get-connection db))
(def _p (.prepareStatement _c "select '{\"foo\": 42}'::jsonb ?| array ['foo']"))
(def _x (.executeQuery _p))
=>
same exception

seancorfield14:03:56

(I bet the PG docs have an answer - but I don't use PG)

seancorfield14:03:17

(and m on my phone)

skuro14:03:06

(every now and then) GIYF it seems:

skuro14:03:19

so ??| it is

2
seancorfield15:03:18

https://github.com/seancorfield/next-jdbc/issues/203 so at least others can find that in the docs in future.

1