对jdbcTemplated查询后的结果进行处理
String sql = '''select work_for_building_ids from face_sign_contract_woker'''
String a = jdbcTemplate.queryForObject(sql,String.class)
用queryForObject接受一个对象,后面为声明对象的类
String sqlId = '''select building_project_name
from face_camera_info
where building_project_id = ?'''
String d = jdbcTemplate.queryForObject(sqlId,String.class,Integer.parseInt(b[i]))
也可以添加参数,只是需要在类声明后面添加,用queryForObject只能对单表单数据进行处理
需要多数据处理queryForList或者queryForMap,不然会报错Incorrect result size: expected 1, actual
String sql = '''select work_for_building_ids from face_sign_contract_woker'''
List<String> list = jdbcTemplate.queryForList(sql)
for(String ids : list) {
try{
System.out.println(ids)
String[] a = ids.split("=")
a[1] = a[1].substring(0,a[1].length()-1)
再遍历从而对数据进行处理
ps:有什么问题多多指教