title: Java Prepared Statement using List and how to return values in list
body: <p>I have multiple values in list and now I want to get data from the database on the bases of these values but I am getting null in return.</p>
  
  <pre><code>List&lt;String&gt; tptTnx = new ArrayList&lt;String&gt;();
  //tptTnx have these values  [101,102,103,104]
  
  //convert list into array
  String[] item = tptTnx.toArray(new String[tptTnx.size()]);  
  </code></pre>
  
  <p>On the bases of the above values, I am using below query and methods.</p>
  
  <pre><code>private static final String SQL_TPT_ACCOUNT = "select customer_id from 
  customer_reference where back_office IN (select upper(bo_cust_number) 
  from gtp_account where account_no IN ? )";
  
  //passing array in method
  public String getCompanyID(String[] item)
  {
      Connection con = null;
      PreparedStatement pstmt = null;
      ResultSet rset = null;
      String companyID = null;
      List&lt;String&gt; cid = null;
      try
      {
          con = PoolBrokerService.getConnection();
          pstmt = con.prepareStatement(SQL_TPT_ACCOUNT);
  
          pstmt.setArray(1, item);
  
  
          rset = pstmt.executeQuery();
  
          while (rset.next())
          {
              //companyID = rset.getString(1);
              cid.add(rset.getString(1));
  
          }
  
          rset.close();
      }
      catch (Exception e)
      {
          GTPException.log("account_id - getAccountID event ", e);
      }
  
      return cid; 
  }
  </code></pre>
  
  <p>the output should be: 401,402,403 but i am getting null values. Please advise how can i pass the list in prepared statement and get result in list or array</p>