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.
List<String> tptTnx = new ArrayList<String>();
//tptTnx have these values [101,102,103,104]
//convert list into array
String[] item = tptTnx.toArray(new String[tptTnx.size()]);
On the bases of the above values, I am using below query and methods.
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<String> 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;
}
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