关于对话框弹出两次的问题

weixin_38356833 2017-04-19 03:07:37

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==btn1){
sid = "401";
}
if(e.getSource()==btn2){
sid = "402";
}
if(e.getSource()==btn3){
sid = "403";
}
if(e.getSource()==btn4){
sid = "404";
}
if(e.getSource()==btn5){
sid = "405";
}
if(e.getSource()==btn6){
sid = "406";
}
if(e.getSource()==btn7){
sid = "407";
}
if(e.getSource()==btn8){
sid = "408";
}
if(e.getSource()==btn9){
sid = "409";
}
if(e.getSource()==btn10){
sid = "410";
}
if(e.getSource()==btn11){
sid = "411";
}
if(e.getSource()==btn12){
sid = "412";
}
String url = "jdbc:odbc:hosiptal";
String SQL = "SELECT * FROM Patient";
Connection conn;
PreparedStatement sql;
ResultSet rs;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e2) {
// TODO: handle exception
}
try {
conn = DriverManager.getConnection(url);
sql = conn.prepareStatement(SQL);
rs = sql.executeQuery();
// while(rs.next()){
if(rs.next()){
String sid1 = rs.getString(12);
if(sid.equals(sid1)){
JOptionPane.showMessageDialog(null, "该病房已满!");

}
else{
JOptionPane.showMessageDialog(null, "该病房空闲!");
this.setVisible(false);
}
}
} catch (SQLException e2) {
// TODO: handle exception
e2.printStackTrace();
}
}
}

一直弹出两次该病房已满,或者弹出两次该病房空闲,第二次弹出时,点确定就不弹出来了。
...全文
148 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

62,626

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧