title: Prepared Statement setString adding unnecessary single quotes to String
body: <p><strong>Background</strong></p>
  
  <p>I am trying to set the contents of an ArrayList into an <code>IN</code> clause in a Db2 SQL statement. I am using the <code>PreparedStatement</code> to build my query. <em>This is our coding standard.</em></p>
  
  <p><strong>What I tried #1</strong></p>
  
  <p>I researched a couple ways to achieve this. I first tried using the <code>setArray()</code> as show in this question: <a href="https://stackoverflow.com/questions/17842211/how-to-use-an-arraylist-as-a-prepared-statement-parameter">How to use an arraylist as a prepared statement parameter</a> The result was I was getting a error of <code>Err com.ibm.db2.jcc.am.SqlFeatureNotSupportedException: [jcc][t4][10344][11773][3.65.110] Data type ARRAY is not supported on the target server. ERRORCODE=-4450, SQLSTATE=0A502</code> After this roadblock, I moved on to #2</p>
  
  <p><strong>What I tried #2</strong></p>
  
  <p>I then tried using the Apache Commons StringUtils to convert the ArrayList into a comma separated String like I needed for my <code>IN</code> clause. The result is that this did exactly what I needed, I have a single String with all my results separated by a comma.</p>
  
  <p><strong>The problem:</strong> </p>
  
  <p>The <code>setString()</code> method is adding single quotes to the beginning and end of my String. I have used this many times, and it has never done this. <strong>Does anyone know if there is a way around this, or an alternative using the PreparedStatement??</strong>  If I use String concatenation my query works. </p>
  
  <p><strong>Code (explained above):</strong></p>
  
  <pre><code>    List&lt;String&gt; selectedStatuses = new ArrayList&lt;String&gt;(); //Used to store contents of scoped var
  
      //Get Contents of Checkbox which are in the form of a List
      selectedStatuses = (List) viewScope.get("selectedStatuses");
  
      String selectedStatusesString = StringUtils.join(selectedStatuses, ",");
  
      .... WHERE ATM_DET_ATM_STAT IN (?)";
      ps.setString(1, selectedStatusesString);
  </code></pre>
  
  <p><strong>Log Value showing correct value of String</strong></p>
  
  <p>DEBUG: selectedStatusesString: <code>'OPEN','CLOSED','WOUNDED','IN PROGRESS'</code></p>
  
  <p><strong>Visual of incorrect result</strong></p>
  
  <p><a href="https://i.stack.imgur.com/Trrse.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Trrse.png" alt="enter image description here"></a></p>
  
  <p>The quotes at the beginning and end are the problem.</p>