spring jdbctemplate demo

对于select 字段1,字段2,字段3这种情形的就用queryForList,然后用hashMap作为行,一个一个去取里面列的值。 

 

 

List<Map<String, Object>> acd_Abn_Calls=getJdbcTemplate().queryForList(sb.toString());
		cmsEntity=new CMSEntity();
		if(null != acd_Abn_Calls &&  acd_Abn_Calls.size()>0){//如果依然是空,则用日志记载
			for(Iterator<Map<String, Object>> iter=acd_Abn_Calls.iterator();iter.hasNext();){
				Map<String, Object> currRow=iter.next();
				int acdCalls=(Integer) currRow.get("acdcalls");
				int abnCalls=(Integer) currRow.get("abncalls");
				int allCalls=acdCalls+abnCalls;
				cmsEntity.setAbnCalls(""+abnCalls);
				cmsEntity.setAcdCalls(""+acdCalls);
				cmsEntity.setAllCalls(""+allCalls);
			}
		}

 

 

 

 

猜你喜欢

转载自wandejun1012.iteye.com/blog/1884268
0条评论
添加一条新回复