想在execute sql时可以中断
------------------------------------
Thread th=new Thread(){
public void run(){
wait.getLb_Text().setText("Exquting,Please Wait!!!");
wait.setVisible(true);
wait.repaint();
try{
stmt=conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE ,java.sql.ResultSet.CONCUR_READ_ONLY );
rs=stmt.executeQuery(sql);
...............................
wait.setVisible(false);
wait.repaint();
} catch(InterruptedException ex){
System.out.println("System interrupted");
}
}
};
wait.thread=th;
th.start();
-------------------------------------------------------------------在相应的 try 语句主体中不能抛出异常 java.lang.InterruptedException
catch(InterruptedException ex){
1 错误
------------------------------------
Thread th=new Thread(){
public void run(){
wait.getLb_Text().setText("Exquting,Please Wait!!!");
wait.setVisible(true);
wait.repaint();
try{
stmt=conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE ,java.sql.ResultSet.CONCUR_READ_ONLY );
rs=stmt.executeQuery(sql);
...............................
wait.setVisible(false);
wait.repaint();
} catch(InterruptedException ex){
System.out.println("System interrupted");
}
}
};
wait.thread=th;
th.start();
-------------------------------------------------------------------在相应的 try 语句主体中不能抛出异常 java.lang.InterruptedException
catch(InterruptedException ex){
1 错误
你可以尝试一下,用别的线程调用这个Statement的close()方法,然后这里捕获SQLException(必须检查错误代码以区别于执行错误)后即可认定是进行了取消操作。
没有实践过,尝试,尝试一下。