I'd like to create a SQL statement like this:
SELECT COUNT(*) FROM table WHERE id IN (1, 2, 3, ..., n)
But I can't figure out how to insert an arbitrary number of values into this statement.
I've tried this:
SELECT COUNT(*) FROM table WHERE id IN (?)
where I use preparedStatement.setString(1, "1, 2, 3, ..., n")
(The string is built through code)
But H2 throws a Data conversion exception
org.h2.jdbc.JdbcSQLException: Data conversion error converting "1, 2, ..."; SQL statement:
How do I bypass this and get H2 to correctly interpret this as a list of integers instead of a string?