
关于HashMap<Integer,HashMap<String,String>>的问题 纠结了许久 请高手帮忙解决
我定义了一个两个哈希,一个是HashMap<String,String>用于存每个流程的详细信息,另一个HashMap<Integer,HashMap<String,St...
我定义了一个两个哈希,一个是HashMap<String,String>用于存每个流程的详细信息,另一个HashMap<Integer,HashMap<String,String>>用于将各个流程汇总。需要从数据库中读取每条流程存入HashMap<String,String>,再将HashMap<String,String>存入HashMap<Integer,HashMap<String,String>>,测试时一共15条记录,最后的结果是每存一条信息流程就把之前的给覆盖了,请各位帮忙看下是什么问题,谢谢。
打印结果为:
{0={exetime=4, editor=null, status=null, trigtype=2, proname=爱爱爱tt, remarks=null, protype=1, execycle=3}}
{0={exetime=4, editor=null, status=null, trigtype=2, proname=爱爱爱fghf, remarks=null, protype=1, execycle=3}, 1={exetime=4, editor=null, status=null, trigtype=2, proname=爱爱爱fghf, remarks=null, protype=1, execycle=3}}
{0={exetime=213, editor=null, status=null, trigtype=234, proname=测试1, remarks=null, protype=123, execycle=3243}, 1={exetime=213, editor=null, status=null, trigtype=234, proname=测试1, remarks=null, protype=123, execycle=3243}, 2={exetime=213, editor=null, status=null, trigtype=234, proname=测试1, remarks=null, protype=123, execycle=3243}}
代码为:
int i = 0;
HashMap<String,String> processDetail = new HashMap<String,String>();
HashMap<Integer,HashMap<String,String>> processDetailSummary = new HashMap<Integer,HashMap<String,String>>();
try {
stmt = conn.createStatement();
ResultSet res = stmt.executeQuery(detailSql);
while (res.next())
{
processDetail.put("proname", res.getString("PRONAME"));
processDetail.put("protype", res.getString("PROTYPE"));
processDetail.put("trigtype", res.getString("TRIGTYPE"));
processDetail.put("execycle", res.getString("EXECYCLE"));
processDetail.put("exetime", res.getString("EXETIME"));
processDetail.put("editor", res.getString("EDITOR"));
processDetail.put("remarks", res.getString("REMARKS"));
processDetail.put("status", res.getString("STATUS"));
processDetailSummary.put(i++, processDetail);
System.out.println(processDetailSummary);
}
} 展开
打印结果为:
{0={exetime=4, editor=null, status=null, trigtype=2, proname=爱爱爱tt, remarks=null, protype=1, execycle=3}}
{0={exetime=4, editor=null, status=null, trigtype=2, proname=爱爱爱fghf, remarks=null, protype=1, execycle=3}, 1={exetime=4, editor=null, status=null, trigtype=2, proname=爱爱爱fghf, remarks=null, protype=1, execycle=3}}
{0={exetime=213, editor=null, status=null, trigtype=234, proname=测试1, remarks=null, protype=123, execycle=3243}, 1={exetime=213, editor=null, status=null, trigtype=234, proname=测试1, remarks=null, protype=123, execycle=3243}, 2={exetime=213, editor=null, status=null, trigtype=234, proname=测试1, remarks=null, protype=123, execycle=3243}}
代码为:
int i = 0;
HashMap<String,String> processDetail = new HashMap<String,String>();
HashMap<Integer,HashMap<String,String>> processDetailSummary = new HashMap<Integer,HashMap<String,String>>();
try {
stmt = conn.createStatement();
ResultSet res = stmt.executeQuery(detailSql);
while (res.next())
{
processDetail.put("proname", res.getString("PRONAME"));
processDetail.put("protype", res.getString("PROTYPE"));
processDetail.put("trigtype", res.getString("TRIGTYPE"));
processDetail.put("execycle", res.getString("EXECYCLE"));
processDetail.put("exetime", res.getString("EXETIME"));
processDetail.put("editor", res.getString("EDITOR"));
processDetail.put("remarks", res.getString("REMARKS"));
processDetail.put("status", res.getString("STATUS"));
processDetailSummary.put(i++, processDetail);
System.out.println(processDetailSummary);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询