时间:2021-07-01 10:21:17 帮助过:20人阅读
请比较两段代码逻辑:
<span style="white-space:pre"> </span><strong>while(rs.next()){</strong> String processID_Temp = rs.getString("processID"); sql = "SELECT count(*) as useFrequence FROM col_summary WHERE form_appid = '"+processID_Temp+"'"; ResultSet rs_useFrequence = dbConn.getSelectResultSet(sql, conn_oa); while(rs_useFrequence.next()){ useFrequence += rs_useFrequence.getString("useFrequence") + ";"; } }修改后:
<span style="white-space:pre"> </span>sql = "SELECT form_appid, count(*) as useFrequence FROM col_summary"; ResultSet rs_useFrequence = dbConn.getSelectResultSet(sql, conn_oa); while(rs_useFrequence.next()){ mapUseFrequence.put(rs_useFrequence.getString("form_appid"), rs_useFrequence.getString("useFrequence")); } <strong>while(rs.next()){</strong> String processID_Temp = rs.getString("processID"); if(mapUseFrequence.containsKey(processID_Temp)){ useFrequence += mapUseFrequence.get(processID_Temp) + ";"; } else{ useFrequence += "0" + ";"; } }没看懂的请留言。。。
版权声明:本文为博主原创文章,未经博主允许不得转载。
去哪网实习总结:如何有效减少对数据库的访问(JavaWeb)
标签:数据库 数据库访问 减少访问数据库次数