The best way to handle the "IN" situations for a JDBC template (in Java or Spring) is to use the NamedParameterJdbcTemplate
from Spring. If you're using environment properties to wire up your data source, one of these should already be available as a bean to autowire in. If not, you can create one just by passing in the JdbcTemplate
that you have.
val days = arrayOf("TUESDAY", "WEDNESDAY")
val namedParamJdbcTemplate = NamedParameterJdbcTemplate(jdbcTemplate) // or autowired in
// make sure this is not an empty collection! In your example it obviously is not empty.
// but if it is being passed in and could be empty, make sure to not query with it,
// otherwise the JdbcTemplate will make a where clause of days NOT IN (), which will fail on execution
val paramMap: Map<String, Any?> = mapOf("days" to days)
namedParamJdbcTemplate.query("select * from days where days not in (:days), paramMap, mapper)