日期:2014-05-18  浏览次数:20604 次

jsp点击多了服务器反映面慢,数据库关闭,说访问地客户端过多!
<%@ page language="java" contentType="text/html; charset=gb2312" %>
<%@ page import="java.sql.*" %>
<jsp:useBean id="DBConn" scope="session" class="mybean.DBConn"/>
<jsp:useBean id="login" class="mybean.CheckUser" scope="session"/>
<%
String arch_User = login.getId();
String arch_Borrow = request.getParameter("arch_Borrow");
String sql;
if("1".equals(arch_Borrow)){
  sql = "Select * From archives where arch_User =\'"+arch_User+"\' and arch_Borrow = \'"+arch_Borrow+"\'";
}else if("2".equals(arch_Borrow)){
  sql = "Select * From archives where arch_Borrow = \'"+arch_Borrow+"\'";
   
}else{
  sql = "Select * From archives where 1=2";  
}
ResultSet rs = DBConn.archivesQuery(sql);

int intPageSize;//一页显示的记录数 
int intRowCount;//记录总数 
int intPageCount;//总页数 
int intPage;//待显示页码
int i; 
String strPage = "";
//设置一页显示的记录数 
intPageSize = 15; 

//取得待显示页码 
strPage = request.getParameter("page"); 
if(strPage==null){//表明在QueryString中没有page这一个参数,此时显示第一页数据 
  intPage = 1; 
}else{//将字符串转换成整型 
  intPage = Integer.parseInt(strPage); 
  if(intPage<1) intPage = 1; 
}

//获取记录总数 
rs.last(); 
intRowCount = rs.getRow(); 

//记算总页数 
intPageCount = (intRowCount+intPageSize-1) / intPageSize; 

//调整待显示的页码 
if(intPage>intPageCount) {
  intPage = intPageCount; 
}
%>
<%
String user_ID = "";
user_ID = login.getId();
if("".equals(user_ID) || user_ID == null){  
  out.println("<script language='javascript'>");
  out.println("alert('你还没有登录,或连接超时,请重新登录!');");
  out.println("window.location = '../index.jsp';");
  out.println("</script>");
}
%>
<script>
  function on_submit(){
  cadre.arch_Actuality.value = "";
  cadre.action = "cadre.jsp";
  cadre.submit();
  }
  function dele_submit(){
  if(confirm("确认删除?")){
  ad_admin_query.action = "ad_admin_sub_dele.jsp";
  ad_admin_query.submit();
  }
   
  }
 
  function Cbg(obj, objColor)
  {
  obj.style.backgroundColor=objColor
  }
</script>
<html>
  <head>
  <title>档案管理 查询</title>
  <link href="../../images/lrkweb.css" rel="stylesheet" type="text/css">
</head>
  <body>
  <form name="cadre" method="POST" action="">

------解决方案--------------------
晕,这么多,哪能看的过来?用数据库连接池