How to set value for in clause in a preparedStatement in JDBC while executing a query.
Example:
connection.prepareStatement("Select * from test where field in (?)");
If this in-clause can hold multiple values how can I do it. Sometimes I know the list of parameters beforehand or sometimes I don’t know beforehand. How to handle this case?
What I do is to add a "?" for each possible value.
Alternative using
StringBuilder(which was the original answer 10+ years ago)And then happily set the params