title: How to set list in prepared statement
body: <p>How can i set list in prepared statement(<strong>statement.setString(1, productCode);</strong> ). 
  See below my code snippet. </p>
  
  <p>Thanks</p>
  
  <pre><code>public static List&lt;Message&gt; listAllWonBids(List&lt;Message&gt; productCode,
      Connection connection) {
  
      List&lt;Message&gt; winners = new ArrayList&lt;Message&gt;();
  
      String sql = "SELECT b.`id`, b.`msisdn` as msisdn ,b.`productname` as productname, b.`productcode` as productcode, max(b.`amount`) as amount FROM  "
          + TableNames.SAVEDBIDSTABLE
          + " b where productcode = ? "
          + " group by amount order by productcode, amount  desc limit 1";
  
      PreparedStatement statement = null;
      ResultSet resultSet = null;
  
      try {
          LOGGER.info(sql);
  
          if (connection == null || connection.isClosed())
              connection = DBConnection.getConnection();
  
          statement = connection.prepareStatement(sql);
  
          **statement.setString(1, productCode);** 
  
          resultSet = statement.executeQuery();
  </code></pre>
  
  <p>NOTE: productCode is coming from another list shown below</p>
  
  <pre><code>public static List&lt;Message&gt; allProductCode(Connection connection) {
      List&lt;Message&gt; productcodes = new ArrayList&lt;Message&gt;();
  
      PreparedStatement statement = null;
      ResultSet resultSet = null;
  
      String sql = "SELECT `productCode` FROM " + TableNames.AUCTIONTABLE1
          + " WHERE date(`endDate`) = curdate() order by `id` desc";
  </code></pre>