Populating Prepared Statement with comma-separated list of integers
<p>If I am populating a Prepared Statement</p>

<pre><code>SELECT CODE FROM MY_TABLE WHERE COMPANY_NO IN (?)
</code></pre>

<p>How could I populate it correctly?</p>

<p>When I do </p>

<pre><code>String sqlResult = "SELECT CODE FROM MY_TABLE WHERE COMPANY_NO IN (?)"

    try {
        PreparedStatement ps = con.prepareStatement(sqlResult, ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);

         ps.setString(1,"4,5");
   }
</code></pre>

<p>then I get</p>

<pre><code>Arithmetic overflow error converting varchar to data type numeric.
</code></pre>

<p>which is because it is being populated as below:</p>

<pre><code>SELECT CODE FROM MY_TABLE WHERE COMPANY_NO IN ('4,5')
</code></pre>