특정 행을 클릭하면 데이터가 mySQL 데이터베이스의 'N'에서 'Y'로 자동 업데이트되는 netbeans에 코드를 작성하고 있습니다. 다음 코드를 작성했습니다. 문제가 있는지 확인하십시오. 디버거를 사용하여 시도했지만 클릭 수 루프 내부로 들어 가지 않습니다.
private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
PreparedStatement ps;
ResultSet rs;
if(evt.getClickCount()==2){
int getsel = jTable2.rowAtPoint(evt.getPoint());
int value = Integer.parseInt(jTable2.getValueAt(getsel, 6).toString());
try{
ps = con.prepareStatement("select * from roomservice where guestid = "+value);
rs = ps.executeQuery();
if(rs.next()){
String taskstatus = rs.getString("taskstatus");
if(taskstatus.equalsIgnoreCase("Y")){
ps = con.prepareStatement("update roomservice set taskstatus = 'N' where guestid= "+value);
ps.executeUpdate();
JOptionPane.showMessageDialog(null, "updated task status");
}else if(taskstatus.equalsIgnoreCase("N")){
ps = con.prepareStatement("update roomservice set taskstatus = 'Y' where guestid= "+value);
ps.executeUpdate();
JOptionPane.showMessageDialog(null, "updated task status");
}
}
}catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
}
}
https://docs.oracle.com/javase/7/docs/api/java/awt/event/MouseEvent.html 살펴보기
두 번 클릭해도 클릭 수가 2가되지 않습니다. 마우스 버튼 1을 누르고 마우스 버튼 2를 누른 다음 버튼을 놓으십시오
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다