title: Java PreparedStatement set IN parameter as int array
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/178479/preparedstatement-in-clause-alternatives">PreparedStatement IN clause alternatives?</a>  </p>
  </blockquote>
  
  
  
  <pre><code>SELECT * FROM tableName WHERE id IN ?
  </code></pre>
  
  <p>I wish to set the PreparedStatement's <code>IN</code> parameter as an <code>int[]</code>.  For example, an integer 
  array of <code>{1, 2, 3, 4}</code> would become <code>IN (1,2,3,4)</code> in the query.</p>
  
  <p><strong>Is there a simple way to achieve this functionality using PreparedStatement's methods, or must I dynamically create the <code>IN</code> parameter as a string by looping over the array?</strong></p>
  
  <p>I imagine something similar to <a href="http://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html#setString%28int,%20java.lang.String%29" rel="nofollow noreferrer"><code>#setString(int parameterIndex, String x)</code></a> but of course for an int array.</p>