易网时代-编程资源站
Welcome
微信登录
编程资源
图片资源库
蚂蚁家优选
PDF转换器
首页
/
操作系统
/
Linux
/
Java中使用SQL的效率分析例子
前年给地图技术审查中心做了一个培训的报名系统,功能需求比较简单,由于当时刚开始摸索java就只能照葫芦画瓢的使用JDBC写的程序。这是中百信公司的遗留项目,我接手过来的,仿照以前的代码写得。出现问题的代码:
<div
id
=
"content"
>
<div
class
=
"locbackground"
>
</div>
<div
class
=
"text"
>
<center>
<h1>
查看培训(会议)报名信息
</h1>
<div><input
type
=
"button"
value
=
"导出会议(培训)报名信息 "
onclick
="location.href="/dtsc/pxbm/outRegisterByConference.jsp?cid=
<
%=request.getParameter("cid
")%>""
/></div>
<br/><table
class
=
"listCases"
width
=
"100%"
border
=
"0"
style
=
"width: 100%; FONT-SIZE: 18px; word-break: break-all"
cellspacing
=
"1"
cellpadding
=
"5"
bgcolor
=#455ca2
>
<thead>
<tr
height
=
"40px"
>
<th
width
=
"70"
bgcolor
=#dcdcdc
align
=
"center"
class
=
""
style
=
"font-size: 14px; FONT-WEIGHT: bold"
>
操作
</th>
<th
width
=
"30"
bgcolor
=#dcdcdc
align
=
"center"
class
=
""
style
=
"font-size: 14px; FONT-WEIGHT: bold"
>
序号
</th>
<th
width
=
"30"
bgcolor
=#dcdcdc
align
=
"center"
class
=
""
style
=
"font-size: 14px; FONT-WEIGHT: bold"
>
姓名
</th>
<th
bgcolor
=#dcdcdc
align
=
"center"
class
=
""
style
=
"font-size: 14px; FONT-WEIGHT: bold"
>
性别
</th>
<th
bgcolor
=#dcdcdc
align
=
"center"
class
=
""
style
=
"font-size: 14px; FONT-WEIGHT: bold"
>
民族
</th>
<th
bgcolor
=#dcdcdc
align
=
"center"
class
=
""
style
=
"font-size: 14px; FONT-WEIGHT: bold"
>
身份证号
</th>
<th
bgcolor
=#dcdcdc
align
=
"center"
class
=
""
style
=
"font-size: 14px; FONT-WEIGHT: bold"
>
工作单位
</th>
<th
bgcolor
=#dcdcdc
align
=
"center"
class
=
""
style
=
"font-size: 14px; FONT-WEIGHT: bold"
>
职务(职称)
</th>
<th
bgcolor
=#dcdcdc
align
=
"center"
class
=
""
style
=
"font-size: 14px; FONT-WEIGHT: bold"
>
手机号码
</th>
<th
bgcolor
=#dcdcdc
align
=
"center"
class
=
""
style
=
"font-size: 14px; FONT-WEIGHT: bold"
>
乘坐何种 交通工具(班次)
</th>
<th
bgcolor
=#dcdcdc
align
=
"center"
class
=
""
style
=
"font-size: 14px; FONT-WEIGHT: bold"
>
到达时间
</th>
<th
bgcolor
=#dcdcdc
align
=
"center"
class
=
""
style
=
"font-size: 14px; FONT-WEIGHT: bold"
>
注册时间
</th>
<th
bgcolor
=#dcdcdc
align
=
"center"
class
=
""
style
=
"font-size: 14px; FONT-WEIGHT: bold"
>
ip地址
</th>
</tr>
</thead>
<
%
Collection
registerId
=
conferenceRegisterAssignOp
.getRegisterIdByConferenceId(Integer.parseInt(request.getParameter("cid")));
Iterator
it
=
registerId
.iterator();
int
index
=
1
;
while (it.hasNext()) {
Integer
integer
= (Integer)it.next();
int
rid
=
integer
.intValue();
Register
temp
=
registerOp
.getCaseInfo(rid);
%
>
<tr>
<td
class
=
"listContent"
>
<a
href
=
"dtsc/pxbm/editRegister.jsp?registerId=<%=temp.getId()%>"
>
编辑
</a>
<br
/>
<br
/>
<a
href
=
"dtsc/pxbm/deleteRegister.jsp?registerId=<%=temp.getId()%>"
>
删除
</a>
<br
/>
<br
/>
<a
href
=
"dtsc/pxbm/editRegister.jsp?registerId=<%=temp.getId()%>"
>
查看详细
</a>
</td>
<td
class
=
"listContent"
><
%=index%
></td>
<td
class
=
"listContent"
><
%=temp.getName() %
></td>
<td
class
=
"listContent"
><
%=CodeSet.getSex(temp.getSex())%
></td>
<td
class
=
"listContent"
><
%=temp.getRace()%
></td>
<td
class
=
"listContent"
><
%=temp.getIdentificationId() %
></td>
<td
class
=
"listContent"
><
%=temp.getDepartment()%
></td>
<td
class
=
"listContent"
><
%=temp.getPositionOrIdentity()%
></td>
<td
class
=
"listContent"
><
%=temp.getMobilephone()%
></td>
<td
class
=
"listContent"
><
%=temp.getDeparture()%
></td>
<td
class
=
"listContent"
><
%=temp.getArrivingTime()%
></td>
<td
class
=
"listContent"
><
%=temp.getRegisterTime()%
></td>
<td
class
=
"listContent"
><
%=temp.getIp()%
></td>
</tr>
<
%
++index;
}
%
>
</table>
</center>
</div>
</div>
因为是嵌在JSP页面的中代码,在java代码后面跟的是一些显示用的HTML代码。注意这一段代码:
Collection registerId = conferenceRegisterAssignOp.getRegisterIdByConferenceId(Integer.parseInt(request.getParameter(
"cid"
)));
Iterator it = registerId.iterator();
int
index = 1;
while
(it.hasNext()) {
Integer integer = (Integer)it.next();
int
rid = integer.intValue();
Register temp = registerOp.getCaseInfo(rid);
这里边先根据cid(培训会议表id)取到了参加本次会议的注册人员的id列表。
Collection registerId = conferenceRegisterAssignOp.getRegisterIdByConferenceId(Integer.parseInt(request.getParameter(
"cid"
)));
然后再遍历这个列表,对每一个注册人员id,都取出这个人员的详细信息。
Register temp = registerOp.getCaseInfo(rid);
这样在报名的数量达到200条的时候运行起来的时间大约为40s到70秒s。由于这个页面的table中的行tr是在后台逐条生成的,再Collection遍历是陆陆续续发送到浏览器的,这样会使浏览器等待页面的时间太长,导致浏览器与后台Web Server的连接超过TimeOut时长,断开连接。反应到前端浏览器的现象就是页面的前半部分加载完成,列表没有全部加载出来。
收藏该网址
版权所有©石家庄振强科技有限公司2024
冀ICP备08103738号-5
网站地图