可能重复:
PreparedStatement IN clause alternatives?
What is the best approach using JDBC for parameterizing an IN clause?
我想执行类似
的语句SELECT * FROM foo WHERE id IN (1,2,3);
在我的java应用程序中。我正在使用postgres 9.0。是否可以将整数数组(int []或Set)作为参数传递?
private void getInfoFromDB() {
PreparedStatement cmd = null;
ResultSet rs = null;
...
try {
cmd = conn.prepareStatement("SELECT * FROM foo WHERE id IN (?)");
cmd.setObject(1, ???);
...
} catch (SQLException e) {
e.PrintStackTrace();
}