How to set integer list when preparing SQL queries in Java

I have a query like this: select * from tbl where ... and colname in (2,3,4)

When I prepare a request (... 'colname in (?)') Using PreparedStatement in Java, which setter method should I call to set these integers? Integers are available in an int array, and the size varies. If that matters, the database is MySQL, and the column in question is of type int.

+3
source share
2 answers

you can use different syntax

WHERE colname = ANY (?)

PreparedStatement.setArray(). java.sql.Array . ANY IN - , SQL.

+3

All Articles