java.sql.SQLException: ResultSet is closed 5
classMysqlimplementsActionListener{publicvoidactionPerformed(ActionEvente){try{Class....
class Mysql implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException eee)
{
System.out.println(""+eee);
}
try
{
String ss=input.getText().trim();
con=DriverManager.getConnection("jdbc:odbc:student");
st=con.createStatement();
String sql="select * from ScoreInfo where ID='"+ss+"'";
ResultSet rs=st.executeQuery(sql);
while(rs.next())
{
String number=rs.getString("ID");
String name=rs.getString("name");
String clas=rs.getString("class");
int chinese=rs.getInt("Chinese");
int english=rs.getInt("English");
int math=rs.getInt("Maths");
show.setText("你删除了:\n");
show.append("学号:"+number+"\n姓名:"+name+"\n班级:"+clas+"\n语文"+chinese+"\n英语 "+english+"\n数学 "+math);
show.append("\n");
sql="delete * from ScoreInfo where ID='"+ss+"'";
st.executeUpdate(sql);
}
}
catch(SQLException ee)
{
JOptionPane.showMessageDialog(Delete.this, "学号不存在","提示对话框",1);
System.out.println(ee);
}
}
}
}
我可以成功删除数据 为什么删除成功后 还是弹出学号不存在的对话框;且提示java.sql.SQLException: ResultSet is closed错误,我想让它能catch到异常,而且正常修改 怎么办啊 求大神!!数据库用的是access 展开
{
public void actionPerformed(ActionEvent e)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException eee)
{
System.out.println(""+eee);
}
try
{
String ss=input.getText().trim();
con=DriverManager.getConnection("jdbc:odbc:student");
st=con.createStatement();
String sql="select * from ScoreInfo where ID='"+ss+"'";
ResultSet rs=st.executeQuery(sql);
while(rs.next())
{
String number=rs.getString("ID");
String name=rs.getString("name");
String clas=rs.getString("class");
int chinese=rs.getInt("Chinese");
int english=rs.getInt("English");
int math=rs.getInt("Maths");
show.setText("你删除了:\n");
show.append("学号:"+number+"\n姓名:"+name+"\n班级:"+clas+"\n语文"+chinese+"\n英语 "+english+"\n数学 "+math);
show.append("\n");
sql="delete * from ScoreInfo where ID='"+ss+"'";
st.executeUpdate(sql);
}
}
catch(SQLException ee)
{
JOptionPane.showMessageDialog(Delete.this, "学号不存在","提示对话框",1);
System.out.println(ee);
}
}
}
}
我可以成功删除数据 为什么删除成功后 还是弹出学号不存在的对话框;且提示java.sql.SQLException: ResultSet is closed错误,我想让它能catch到异常,而且正常修改 怎么办啊 求大神!!数据库用的是access 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询