String selectDsDept = select idun_code from t_dept where un_code in values; ListMapString Object dsMapList = jdbcTemplatequeryForListselectDsDeptCollectionssingletonMapvalues dsUnicodeList;报错Prepare
The error message suggests that the parameter index is out of range because there are no parameters present in the query.
In this case, it seems like the parameter :values is not being recognized as a parameter placeholder by the jdbcTemplate.queryForList() method.
To fix this issue, you can try using the NamedParameterJdbcTemplate class instead, which supports named parameters in queries. Here's an example of how you can modify your code:
String selectDsDept = "select id, un_code from t_dept where un_code in (:values)";
Map<String, Object> paramMap = Collections.singletonMap("values", dsUnicodeList);
List<Map<String, Object>> dsMapList = namedParameterJdbcTemplate.queryForList(selectDsDept, paramMap);
Make sure to initialize the namedParameterJdbcTemplate object with the correct DataSource before using it
原文地址: https://www.cveoy.top/t/topic/iUkS 著作权归作者所有。请勿转载和采集!