PreparedStatement IN clause alternatives?

前端 未结 30 3883
情歌与酒
情歌与酒 2020-11-21 05:19

What are the best workarounds for using a SQL IN clause with instances of java.sql.PreparedStatement, which is not supported for multiple values du

30条回答
  •  我在风中等你
    2020-11-21 05:49

    This worked for me (psuedocode):

    public class SqlHelper
    {
        public static final ArrayListplatformList = new ArrayList<>(Arrays.asList("iOS","Android","Windows","Mac"));
    
        public static final String testQuery = "select * from devices where platform_nm in (:PLATFORM_NAME)";
    }
    

    specicify binding :

    public class Test extends NamedParameterJdbcDaoSupport
    public List runQuery()
    {
        //define rowMapper to insert in object of SampleClass
        final Map map = new HashMap<>();
        map.put("PLATFORM_LIST",DeviceDataSyncQueryConstants.platformList);
        return getNamedParameterJdbcTemplate().query(SqlHelper.testQuery, map, rowMapper)
    }
    

提交回复
热议问题