pass unknown number of parameters to IN clause using JDBC and Postgres
问题 My query looks like this, and performs well: select * from table t where (t.one,t.two,t.three) in ( (11,12,13), (21,22,23) ); Now the number of these triplets within the in statement will vary, so I'm trying to do the following with JDBC: String sql = "select * from table where (one, two, three) in (select * from unnest(?::smallint[], ?::integer[], ?::integer[]))" // conn is the java.sql.Connection PreparedStatement ps = conn.prepareStatement(sql); ps.setArray(1, conn.createArrayOf("smallint"