原来有个软件,用ASP做的,一个页面,一下子返回几百行记录,比较快我现在用JSP,一下子返回几百行,就很慢,为什么?有办法提高吗?还是TOMCAT就是很慢还有,操作那个一下子返回几百行的记录的页面,如果连续操作该页面,会导致服务器短暂瘫痪,1分钟左右难道TOMCAT性能远不如IIS??
解决方案 »
- IE8中下载文件时,在线打开txt文件时弹出两个窗口?
- WEB运行一段时间后,oracle连接自动关闭,请大家帮忙分析分析!!!!!!!!!!!!!!!!!!!
- form表单用get方法提交的疑问
- struts2 的fielderror验证后action跳转问题。急。
- netBeans拼寫檢查
- ------------100分求类似http://www.7dn.cn网站上的下拉菜单,不甚感激---------------
- 从文本文件中读取中文产生的乱码
- 用JSP做一个带验证码的登陆系统的问题。
- 求一套jsp开发得聊天室程序
- STRUTS2配置都正确却找不到action?
- 请教:如何实现,若两个用户在某一时刻都打开了一个页面,进行提醒
- 请教apache与tomcat整合后的路径问题
String name="";
String post="";
String sex="";
String birthday="";
String education="";
String policelevel="";
String policerank="";
String mobile="";
String policenum="";
// String depid="";
String depname="";
String postname="";
String postview="";
String orderid=""; if(depids!=null)
sql="select depid,post,policenum,id, name,sex,birthday,education,postlevel,policerank,mobile from police where depid='"+depids+"' order by hiddenpost";
if(depids==null||(depids!=null&&depids.equals("")))
sql="select depid,post,policenum,id, name,sex,birthday,education,postlevel,policerank,mobile from police order by depid,hiddenpost ";
// ResultSet rs=null; // out.println(sql); ResultSet rs1=null;
rs=s_item.executeQuery(sql); while(rs!=null&&rs.next()){
postview="";
depid=rs.getString("depid");
post=rs.getString("post");
policenum=rs.getString("policenum");
id=rs.getString("id"); String sql1="select * from department where id="+depid;
rs1=s_item.executeQuery(sql1);
if(rs1!=null&&rs1.next())
depname=rs1.getString("depname"); if(rs1!=null)
rs1.close();
s_item.closeStmt();
s_item.closeConn();
i=0;
name=rs.getString("name");
// post=rs.getString("post");
sex=rs.getString("sex");
birthday=rs.getString("birthday");
education=rs.getString("education");
policelevel=rs.getString("postlevel");
policerank=rs.getString("policerank");
mobile=rs.getString("mobile");
// policenum=rs.getString("policenum"); // out.println(inside.length());
if(sex==null||(sex!=null&&sex.equals(" ")))
sex=" ";
if(birthday==null||(birthday!=null&&birthday.equals("1900-01-01 00:00:00.0")))
birthday=" ";
else
birthday=birthday.substring(0,10);
if(education==null||(education!=null&&education.equals("")))
education=" ";
if(policelevel==null||(policelevel!=null&&policelevel.equals("")))
policelevel=" ";
if(policerank==null||(policerank!=null&&policerank.equals("")))
policerank=" ";
if(mobile==null||(mobile!=null&&mobile.equals("")))
mobile=" ";
if(post==null||(post!=null&&post.equals("")))
post=" ";
// out.println(birthday); %>
<tr class="tdbg">
<td align="center" height="27"><%=depname%></td>
<td align="center"><a href="#" onclick="openwin1(<%=policenum%>)"><%=name%></a></td>
<td align="center" height="27"><%=post%></td>
<td align="center"><%=policelevel%></td>
<td align="center" height="27"><%=sex%></td>
<td align="center"><%=birthday%></td>
<td align="center"><%=education%></td>
<td align="center" height="27"><%=policenum%></td>
<td align="center"><%=policerank%></td>
<td ><%=mobile%></td>
<%
if(depids==null||(depids!=null&&depids.equals(""))){
%>
<td ><font size=2px><a href="#" onclick="openwin1(<%=id%>)">查看</a> <a href="#" onclick="openwin3(<%=id%>)">修改</a> <a href="#" onclick="openwin4(<%=id%>)"> 删除 </a><a href="#" onclick="openwin2(<%=id%>,'move')">调动</a> <a href="#" onclick="openwin2(<%=id%>,'punish')">奖惩</a> <a href="#" onclick="openwin2(<%=id%>,'leave')">请假</a></font></td>
<%
}
else{
%>
<td ><font size=2px><a href="#" onclick="openwin1(<%=id%>)">查看</a> <a href="#" onclick="openwin3(<%=id%>)">修改</a> <a href="#" onclick="openwin4(<%=id%>)"> 删除 </a><a href="totalorder.jsp?action=up&&id=<%=id%>&&depid=<%=depids%>">上移</a> <a href="totalorder.jsp?action=down&&id=<%=id%>&&depid=<%=depids%>">下移</a> <a href="#" onclick="openwin2(<%=id%>,'move')">调动</a> <a href="#" onclick="openwin2(<%=id%>,'punish')">奖惩</a> <a href="#" onclick="openwin2(<%=id%>,'leave')">请假</a></font></td>
<%
}
%>
</tr>
<%
} if(rs!=null)
rs.close();
s_item.closeStmt();
s_item.closeConn(); %>
问题2:如果while里你每次都建立的连接就相当于在while循环里进行了上百次的连接开启与关闭
总之也不知道是你括号没复制全还是代码没复制全,我感觉是你这段while写的有问题
我有俩问题问题1:在while里进行第一次rs1的查询就连接关闭了,第二次又是怎么建立的连接?我没有找到
问题2:如果while里你每次都建立的连接就相当于在while循环里进行了上百次的连接开启与关闭
总之也不知道是你括号没复制全还是代码没复制全,我感觉是你这段while写的有问题
[/Quo
谢谢你的提醒。问题出在这几行String sql1="select * from department where id="+depid;
rs1=s_item.executeQuery(sql1);
if(rs1!=null&&rs1.next())
depname=rs1.getString("depname");if(rs1!=null)rs1.close();
s_item.closeStmt();
s_item.closeConn();我去掉之后,速度快乐很多