Java编写的使用List的语句以及如何在List中返回值
我在列表中有多个值,现在我想根据这些值从数据库中获取数据,但得到的结果是nullJava编写的使用List的语句以及如何在List中返回值,java,arrays,list,jdbc,prepared-statement,Java,Arrays,List,Jdbc,Prepared Statement,我在列表中有多个值,现在我想根据这些值从数据库中获取数据,但得到的结果是null 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()]); 基于上述值,我使用以下查询和方
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()]);
基于上述值,我使用以下查询和方法
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;
}
输出应该是:401402403,但我得到的是空值。请告知我如何在准备好的语句中传递列表并在列表或数组中获得结果它不是重复的。我尝试了网络上所有可用的解决方案,然后我发布了这个问题。有什么变化吗?如果我传递了单个值,我得到了结果,但是多个值不起作用,它不重复。我尝试了网络上所有可用的解决方案,然后我发布了这个问题。有什么变化吗?如果我传递了单个值,我得到了结果,但是多个值不起作用