Possible Duplicate:
PreparedStatement IN clause alternatives?
What is the best approach using JDBC for parameterizing an IN clause?
I want to execute a statement like
SELECT * FROM foo WHERE id IN (1,2,3);
in my java application. I'm using postgres 9.0. Is it possible to pass an integer array (int[] or Set) as parameter?
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();
}