Can’t pass multiple arguments to SQL statement into wildcard [duplicate]

You can use the following way

String inSql = String.join(",", Collections.nCopies(ids.size(), "?"));
 


List<Account> result = jdbcTemplate.query(
      String.format("SELECT ID, NAME FROM ACCOUNT WHERE STATUS = 'OK' AND ID IN  (%s)", inSql), 
      ids.toArray(), 
      (rs, rowNum) -> new Account(rs.getInt("ID"), rs.getString("NAME")));

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top