Java提示结果集关闭
intdanxscore=0;intduoxscore=0;inttkscore=0;intscore=0;Connectioncon;ResultSetrs1=null...
int danxscore=0;
int duoxscore=0;
int tkscore=0;
int score=0;
Connection con;
ResultSet rs1=null;
ResultSet rs2=null;
Statement sql=null;
Statement sqa=null;
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}catch(ClassNotFoundException event){}
try{
con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=ksxt","sa","123456");
sql=con.createStatement();
String condition1="select biaoti,daan from danxuan ";
String condition2="select * from danxda";
rs1=sql.executeQuery(condition1);
if (rs1!= null) {
while(rs1.next()){
String s1=rs1.getString(1);
out.println(s1);
rs2=sql.executeQuery(condition2);
while(rs2.next())
{
String s2=rs2.getString(1);
out.println(s2);
if(s1.equals(s2))
{
if(rs2.getString(2).equals(rs1.getString(2)))
{
out.println(s1);
out.println(s2);
danxscore+=6;
}
}
}
}
} else{
out.println("无数据");}
out.println(danxscore);
//con.close();
}catch(SQLException e){
out.println(e);
}
输出:1 1 com.microsoft.sqlserver.jdbc.SQLServerException: 结果集已关闭。 展开
int duoxscore=0;
int tkscore=0;
int score=0;
Connection con;
ResultSet rs1=null;
ResultSet rs2=null;
Statement sql=null;
Statement sqa=null;
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}catch(ClassNotFoundException event){}
try{
con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=ksxt","sa","123456");
sql=con.createStatement();
String condition1="select biaoti,daan from danxuan ";
String condition2="select * from danxda";
rs1=sql.executeQuery(condition1);
if (rs1!= null) {
while(rs1.next()){
String s1=rs1.getString(1);
out.println(s1);
rs2=sql.executeQuery(condition2);
while(rs2.next())
{
String s2=rs2.getString(1);
out.println(s2);
if(s1.equals(s2))
{
if(rs2.getString(2).equals(rs1.getString(2)))
{
out.println(s1);
out.println(s2);
danxscore+=6;
}
}
}
}
} else{
out.println("无数据");}
out.println(danxscore);
//con.close();
}catch(SQLException e){
out.println(e);
}
输出:1 1 com.microsoft.sqlserver.jdbc.SQLServerException: 结果集已关闭。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询