com.microsoft.sqlserver.jdbc.SQLServerException: 结果集已关闭.
这是代码try{ResultSetrs=stmt1.executeQuery("SELECT*FROM词库");//Strings=jt2.getText().trim(...
这是代码
try {
ResultSet rs = stmt1.executeQuery("SELECT * FROM 词库");
//String s=jt2.getText().trim();
//System.out.print("b");
//System.out.print(rs.next());
while(rs.next()){
word = rs.getString("单词");
mean = rs.getString("释义");
//System.out.print(word.equals(jt1.getText()));
System.out.println(word+" "+mean);
if(!word.equals(jt1.getText())) {
String s1=jt1.getText().trim();
System.out.print(s1);
String s2=jt2.getText().trim();
System.out.print(s2);
String temp="INSERT INTO 词库 VALUES ('"+s1+"','"+s2+"')";
stmt1.executeUpdate(temp);
JOptionPane.showMessageDialog(null,"添加成功!","恭喜",
JOptionPane.WARNING_MESSAGE);
dispose();
}
} 展开
try {
ResultSet rs = stmt1.executeQuery("SELECT * FROM 词库");
//String s=jt2.getText().trim();
//System.out.print("b");
//System.out.print(rs.next());
while(rs.next()){
word = rs.getString("单词");
mean = rs.getString("释义");
//System.out.print(word.equals(jt1.getText()));
System.out.println(word+" "+mean);
if(!word.equals(jt1.getText())) {
String s1=jt1.getText().trim();
System.out.print(s1);
String s2=jt2.getText().trim();
System.out.print(s2);
String temp="INSERT INTO 词库 VALUES ('"+s1+"','"+s2+"')";
stmt1.executeUpdate(temp);
JOptionPane.showMessageDialog(null,"添加成功!","恭喜",
JOptionPane.WARNING_MESSAGE);
dispose();
}
} 展开
1个回答
展开全部
发个全代码把。。代码不全哪中迅不培银知道。。。应该是你已经关闭了sql连接
私信我
打字不易,如满李此意,望采纳。
私信我
打字不易,如满李此意,望采纳。
追问
我把while语句里的if语句拿走就不会出现这种错误,为什么?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询