再谈:java.net.SocketException: Connection reset by peer: socket write error
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.sql.*"%>
<html>
<head>
<title>
信息录入
</title>
<link href="../css/public.css" rel="stylesheet" type="text/css"/>
<script language="javascript">
function check(form)
{
form.Result.value=form.Result.value.substring(0,form.Result.value.length-1);
alert(form.Result.value);
form.submit();
return true;
}
function doSubmit(form)
{
alert(form.name);
}
</script>
</head>
<body>
<form action="test.jsp" method="POST" name="form1" onsubmit="return check(this);">
<table border="0" align="center" cellpadding="0" cellspacing="0" width="98%">
<%
try
{
String strTableName=request.getParameter("name");
String strTableID="";
String tmp = "";
try {
byte[] by = strTableName.getBytes("ISO-8859-1");
tmp = new String(by);
}
catch (Exception e) {
}
strTableName=tmp;
DbConn db=new DbConn();
Connection cn=db.getConnection();
Statement stm=cn.createStatement();
ResultSet rst_ID=stm.executeQuery("select tableID from tblgovTableName where TableName='"+strTableName+"'");
if(rst_ID.next())
{
strTableID=rst_ID.getString("TableID");
buff.addTable(strTableID);
}
else
{
out.println("<center><h2>参数错误,请查证!</h2></center>");
}
try
{
rst_ID.close();
rst_ID=null;
stm.close();
stm=null;
cn.close();
cn=null;
}catch(Exception e) {}
int pageCount=0;
int curPageIndex=0;
String pageString="";
if(request.getParameter("Page")==null)
{
curPageIndex=1;
}
else
{
curPageIndex=Integer.parseInt(request.getParameter("Page"));
}
if(request.getParameter("PageCount")!=null)
{
pageCount=Integer.parseInt(request.getParameter("PageCount"));
}
if(curPageIndex>pageCount)
{
curPageIndex=pageCount;
}
if(curPageIndex<1)
{
curPageIndex=1;
}
ResultSet rst_Page=null;
Connection conn=db.getConnection();
Statement stmt=conn.createStatement();
String sql_Page="exec spGetInfoPage '"+strTableID+"','"+curPageIndex+"'";
rst_Page=stmt.executeQuery(sql_Page);
while(rst_Page.next())
{
/**
* Find out the all Fields of current main Table .
*/
pageCount=rst_Page.getInt("PageCount");
pageString=rst_Page.getString("PageString");
}
//Close the rst_Table
try
{
rst_Page.close();
rst_Page=null;
stmt.close();
stmt=null;
conn.close();
conn=null;
}catch(Exception ex) {}
if(pageCount!=0)
{
String[] PerPage=pageString.split(",");
String curSelectNumber=PerPage[curPageIndex-1];
ResultSet rst_Field=null;
String sql_Field="";
if(curSelectNumber.length()<5) //the number 5 can use any other,but must more than maxDisplay Page Length.
{
sql_Field="exec spGetInfoResult '"+strTableID+"','"+curSelectNumber+"'";
}
else
{
//strTableID=curSelectNumber;
sql_Field="exec spGetInfoResult '','"+curSelectNumber+"'";
}
rst_Field=db.ExecQueryNewTwo(sql_Field);
out.println(strTableName+"<br>");
int i=0;
/**
* 在此对数据进行分页处理,分页显示数据,rst_Field是当前页将要显示的数据
*/
%>
<tr>
<%
while(rst_Field.next())
{
/**
*
*Display the all Feilds of Current Result .
*/
i++;
String FID=rst_Field.getString("FieldID").trim();
String FName=rst_Field.getString("F_Name").trim();
String FType=rst_Field.getString("F_Type").trim();
String CodeSetID=rst_Field.getString("CodesetID").trim();
int DW=Integer.parseInt(rst_Field.getString("DisplayWidth").trim());
int Len=Integer.parseInt(rst_Field.getString("F_Len").trim());
//out.println(FName+" "+FType+" "+CodeSetID);
%>
<td align="right">
<%=FName%>
</td>
<td align="left">
<%
if (Len>50 && FType=="A")
{
%>
yes.............
<%
}
else
{
%>
oh,no...........
<%
}
%>
</td>
<%
if (i%2==0)
{
%>
</tr>
<%
}
}
//Close the rst_Field
try
{
rst_Field.close();
rst_Field=null;
}catch(Exception ed) {}
}
else
{
// ERROR OR EMPTY.
out.println("警告:没有任何数据,请查证!");
}
%>
<!--Table Footer -->
<tr align="right">
<td width=100% bgcolor="#ffffff" colspan="4" valign="middle" height="20" bordercolordark="#FFFFFF">
<p align="right">
<font color="#000000">共<%=pageCount%>步 第<%=curPageIndex%>步</font>
<%if (curPageIndex > 1) {%>
<a href="test.jsp?name=<%=strTableName%>&Page=<%=(curPageIndex - 1)%>&PageCount=<%=pageCount%>"
onclick="return check(form1);" >
<%
}
%>
<img src="../icons/bprevious.gif" border=0></a>
<%
if (curPageIndex < pageCount) {
%>
<a href="test.jsp?name=<%=strTableName%>&Page=<%=(curPageIndex + 1)%>&PageCount=<%=pageCount%>"
onclick="return check(form1);" >
<%
}
%>
<img src="../icons/bnext.gif" border=0></a>
</td>
</tr>
<tr align="center">
<td colspan="4">
<input type="button" name="btncancel" value=".取消." onclick="window.close();"/>
<input type="hidden" name="Result" value=""/>
</td>
</tr>
<%
}catch(Exception ee) {out.println(ee.getMessage());}
%>
</table>
</form>
</body>
</html>
以下错误信息,在浏览这个页面的时候,偶尔会出现这个错误,有时它又不出错,为什么???
信息如下: