如何在 JDBC 中设置整数数组(用setArrayfor 子句准备的语句?
String query = "SELECT * FROM table WHERE id IN (?)";
// other things.
// ArrayList<Integer> some_ids;
preparedStatement.setArray(1, conn.createArrayOf("INTEGER", some_ids.toArray()));
Run Code Online (Sandbox Code Playgroud)
它编译,但执行从 Postgres 返回它。
ERROR: cannot cast type integer[] to integer
Run Code Online (Sandbox Code Playgroud)