首页 新闻 会员 周边

怎么样把我一条select查询出来的集合放在指定map里面去?

0
悬赏园豆:20 [已关闭问题] 关闭于 2013-12-10 10:21

左边三个是用户名,现在是要把每个用户名所录入的服装信息分别存进map

我想要的效果就是(国际级:(春服)(夏服)(冬服)....)(韬光养晦:(春服)(夏服)(冬服)....)

workIT的主页 workIT | 初学一级 | 园豆:185
提问于:2013-12-05 14:10
< >
分享
所有回答(1)
0

HashMap<String, SomExam> mapOfGuoJia = new HashMap<String, SomExam>();
HashMap<String, SomExam> mapOfTaoGuang = new HashMap<String, SomExam>();

try {
Connection conn = DataSourceUtils.getConnection(jdbcTemplate.getDataSource());
CallableStatement cs = conn.prepareCall(sql.toString());
try {
//赋值参数
cs.setInt(1, fid.intValue());
cs.setString(2, stime.getTime());
cs.setString(3, etime.getTime());
ResultSet r = cs.executeQuery();
while (r.next()) {
SomExam temp = new SomExam();
temp.setname1(r.getString("name1"));
temp.setName(r.getString("name"));


if (){
mapOfGuoJia.put(temp.getName, temp); //key值需要自己去定义
}else{
mapOfTaoGuang.put(temp.getName, temp); //key值需要自己去定义
}

}
} catch (Exception e) {
e.printStackTrace();
} finally {
cs.close();
DataSourceUtils.releaseConnection(conn,
jdbcTemplate.getDataSource());
}
} catch (Exception e) {
e.printStackTrace();
}

bitbug | 园豆:470 (菜鸟二级) | 2013-12-05 14:26
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册