I am using Java 1.7 and JDBC 4 and Postgres. I am trying to use PreparedStatement with an array to populate an SQL statement. But in the SQL generation, there seems to be "{" and "}". Here is the code:
PreparedStatement ptmt = connection.prepareStatement("select * from foo where id in (?)"); String[] values = new String[3]; values[0] = "a"; values[1] = "b"; values[2] = "c"; ptmt.setArray(1, connection.createArrayOf("text", values));
The resulting SQL is as follows:
select * from foo where id in ('{"a","b","c"}')
What can't work. Here's how it should look:
select * from foo where id in ("a","b","c")
or
select * from foo where id in ('a','b','c')
What am I missing here?
source share