關(guān)于刪除功能 數(shù)據(jù)庫里沒有的id 進行刪除操作還提示刪除成功 如何優(yōu)化大神們
?else if(OPERATION_DELETE.equals(in.toUpperCase())
? ?||OPERATION_DELETE.substring(0, 1).equals(in.toUpperCase())){
System.out.println("輸入需要刪除女神的ID:");
Scanner s=new Scanner(System.in);
try {
action.del(Integer.valueOf(s.nextInt()));
System.out.println("刪除成功");
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("請輸入數(shù)字");
} catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println("輸入的ID不存在 ?重新輸入");
}
?
}
2017-03-05
刪除之前先查詢一次,如果沒有提示沒有此記錄,有的話刪除,完事