📄 result.jsp
字号:
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>结果</title>
</head>
<body>
<%!
public String getStr(String s){
String str=s;
try{
byte b[]=str.getBytes("ISO-8859-1");
str=new String(b);
return str;
}
catch(Exception e){return null;}
}
%>
<form action="result.jsp" method="post">
<%
int factCounter=Integer.parseInt((session.getAttribute("factCounter")).toString());//接受之前所得的非目标事实个数的参数
//out.print(factCounter);
int []factDetail=new int [factCounter];
//String s=request.getParameter("RadioGroup"+1);
//out.print(s);
for (int i=0;i<factCounter;i++)
{
factDetail[i]=Integer.parseInt(request.getParameter("RadioGroup"+i));
//out.println(i+" : "+fact[i]+"\n");
}
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url = "jdbc:mysql://localhost:3306/animal?user=root&password=";
Connection conn = DriverManager.getConnection(url);
Connection conn2 = DriverManager.getConnection(url);
Connection conn3 = DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
Statement stmt2=conn2.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
Statement stmt3=conn3.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); //数据库连接
String sql ="select * from db ;";
ResultSet rs2=stmt.executeQuery(sql);
rs2.last();
int n=rs2.getRow();
//out.print("n:"+n);
sql ="select * from db where isdes=0;";
ResultSet rs1=stmt.executeQuery(sql);
int j=0;
int x=0;
rs1.last();
int coun=rs1.getRow();
rs1.first();
String in =new String ();
int []temp=new int[n];
/*while(coun>0){
if(factDetail[j]==1){
in+=" insert into test values("+rs1.getInt(1)+");";
}
j++;
coun--;
rs1.next();
}
stmt.execute(in);*/
while(coun>0){
if(factDetail[j]==1)
{temp[x]=rs1.getInt(1);x++;}
j++;
coun--;
rs1.next();
}
boolean isThereNew=true;
boolean isAllOld=false;
int isAllok=0;
int k=0;
int l=0;
j=0;
int num=2;
/*for (int f=0;f<n;f++)
if(temp[f]!=0)
out.print(temp[f] +" ");%><br /><%*/
while (!isAllOld)
{
ResultSet rsPIPEI1;
ResultSet rsPIPEI2;
ResultSet rstemp;
while (j<n){
sql="select * from rb where preid="+temp[j];
rsPIPEI1=stmt.executeQuery(sql);
rsPIPEI1.last();
int t=rsPIPEI1.getRow();
rsPIPEI1.first();
//out.print(j+" :");
while(t>0)
{
int tempInt=rsPIPEI1.getInt(3);
sql="select distinct rid from rb where resid="+tempInt+";";
rstemp=stmt2.executeQuery(sql);
rstemp.last();
int rows=rstemp.getRow();
int rowjudge=0;
rstemp.first();
while(rowjudge<rows)
{
int tempInt2=rstemp.getInt(1);
sql="select * from rb where rid="+tempInt2;
sql+=" and resid="+tempInt+";";
rsPIPEI2=stmt3.executeQuery(sql);
rsPIPEI2.last();
int correct=rsPIPEI2.getRow();
rsPIPEI2.first();
isThereNew=false;
while (l<n)
{
if(isAllok==correct) {isThereNew=true;break;}
if(temp[l]==rsPIPEI2.getInt(2)) {isAllok++;rsPIPEI2.next();l=0;continue;}
l++;
}//out.print("2 : "+tempInt+" ,"+tempInt2+" ,"+correct+" ,"+isAllok);
l=0;
if(isThereNew){
boolean tag=true;
for (int f=0;f<n;f++)
if (temp[f]==tempInt){tag=false; break;}
if (tag){temp[x]=tempInt;x++;isAllOld=false;}
else isAllOld=true;
}
else isAllOld=true;
rstemp.next();
isAllok=0;
rowjudge++;
}
//out.print(tempInt+" ");
/*isThereNew=true;
while (k<n){
if(temp[k]==tempInt) {isThereNew=false;break;}
k++;
}
//if(k==n && temp[x]!=tempInt) isThereNew=true;
k=0;*/
/*for (int f=0;f<n;f++)
if(temp[f]!=0)
out.print(temp[f] +" ");%><br /><%*/
rsPIPEI1.next();
t--;
//out.print("temp");
//for (int f=0;f<n;f++)
//if(temp[f]!=0)
//out.print(temp[f] +" ");
/*%><br /><%*/
}
isAllOld=true;
/*%><br /><%*/
j++;
}
}
ResultSet finalrs;
boolean hasResult=false;
for (int a=0;a<n;a++)
{
try{
sql="select * from db where did=";
sql+=temp[a]+" ;";
//out.print(a+":"+temp[a]+" ,"+sql);
finalrs=stmt.executeQuery(sql);
finalrs.first();
//out.print(finalrs.getInt(3));
int t1=finalrs.getInt(3);
//int t3=finalrs.getInt(3);
String t2=getStr(finalrs.getString(2));
//out.print(t1+" ,"+t2+" ,");
if(t1==1) {out.print("您想要的结果是"+t2);hasResult=true;break;}
}
catch(Exception e)
{
break;
}
}
if(!hasResult) out.print("没有您输入所能得到的结果!");
/*%><br /><%*/
/*for (int f=0;f<n;f++)
if(temp[f]!=0)
out.print(temp[f] +" ");*/
%>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -