How to set values for sql with IN which can hold variable numbers like, … WHERE …status IN (4, 6,7 ); ?
PreparedStatement ps = con.prepareStatement(
"SELECT ea.* FROM employeeAssignment ea "
+ "JOIN employee e ON e.employeeID = ea.employeeID "
+ "WHERE e.resourceID = ? and ea.status IN (?);");
ps.setInt(1, 75);
ps.setInt(2, someArray/some thing other?);
You could generate the SQL IN clause according to how many status codes you need to pass in. So if your status is
IN (4,6,7)then you could generate an SQL statement ending with the same number of question marks as codes:IN (?,?,?).