//处理queryForMap
public Map<String, Object> getResults(String userId) {
Map<String,Object> map = new HashMap<>();
try{
String sql = “select t.* from tablename t where t.xh=?”;
map = jdbcTemplate.queryForMap(sql, userId);
}catch(Exception e){
LogUtil.error(“获取数据失败:” + e.toString(), e);
map=null;
}
return map;
}
//处理queryForObject
try {
xfjh = jdbcTemplate.queryForObject(sql, Integer.class, userId);
dataMap.put(“xfjh”, String.valueOf(xfjh));
dataMap.put(“sfysz”, true);
} catch (DataAccessException e) {
xfjh = 0;
dataMap.put(“xfjh”, “0”);
dataMap.put(“sfysz”, false);
}
版权声明:本文为u013592116原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。