title: select query where in clause problem in spring jdbcTemplate
body: <p>public class CountryMasterModel {
  private String countryNames[];</p>
  <pre><code>public String[] getCountryNames() {
      return countryNames;
  }
  
  public void setCountryNames(String[] countryNames) {
      this.countryNames = countryNames;
  }
  </code></pre>
  <p>}</p>
  <p>public interface CountryMasterService {</p>
  <pre><code>List&lt;String&gt; getCountryData(String compCode, CountryMasterModel model) throws SQLException, DataAccessException;
  </code></pre>
  <p>}</p>
  <p>@Component
  public class CountryMasterDAO implements CountryMasterService{</p>
  <pre><code>@Autowired
  private JdbcTemplate template;
  
  @Override
  public List&lt;String&gt; getCountryData(CountryMasterModel model) throws SQLException, DataAccessException {
      this.template = new JdbcTemplate(DBMSSQL.getDBCon());
      System.out.println(template.getDataSource().getConnection().getCatalog());
      List&lt;String&gt; ids = Arrays.asList(model.getCountryNames());
      MapSqlParameterSource parameters = new MapSqlParameterSource();
      parameters.addValue(&quot;countryName&quot;, ids);
      List&lt;String&gt; list = new ArrayList&lt;String&gt;();
      list = this.template.query(&quot;SELECT NAME FROM country_master WHERE NAME IN (?)&quot;, new Object[] { ids },
              new CountryMasterResultSetExtrator());
      System.out.println(&quot;ids = &quot; + ids);
      System.out.println(&quot;list = &quot; + list.get(0));
      return list;
  }
  
  public static void main(String[] args) throws DataAccessException, SQLException {
      CountryMasterModel bean = new CountryMasterModel();
      String a[] = { &quot;India&quot;, &quot;Pakistan&quot;, &quot;Russia&quot;, &quot;America&quot;,};
      bean.setCountryNames(a);
      System.out.println(StringUtil.getStringArray(a));
      List&lt;String&gt; list = new CountryMasterDAO().getCountryData(bean);
      System.out.println(&quot;List Size = &quot;+list.size());
  }
  </code></pre>
  <p>}</p>
  <p><a href="https://i.stack.imgur.com/eo3fG.jpg" rel="nofollow noreferrer">enter image description here</a></p>