1
日付をjdatechooserで更新しようとするとデータベースに保存できません。データベースの日付が表示されません。 MM/dd/yyyyですか?私はSQLiteデータベースを使用し、あなたが入力した日付を取得するためにJDateChooser.getDate()
を呼び出す必要がjdatechooserの日付をJava eclipseで更新する方法
try{
String t10= comboBoxGen.getSelectedItem().toString();
String JD= dateChooser.getDateFormatString();
String t1= textFieldID.getText();
String t2= textFieldFN.getText();
String t3= textFieldLN.getText();
String t4= textFieldCN.getText();
String t5= textFieldAge.getText();
String t6= textFieldDep.getText();
String t7= textFieldMob.getText();
String t8= textFieldSal.getText();
String BD= dateChooser1.getDateFormatString();
// String t9= textFieldBD.getText();
// String t10= textFieldGen.getText();
String t11= textFieldAdd.getText();
String t12= textFieldPos.getText();
// String t13= textFieldJD.getText();
if(t1.length()>4 || t1.length()==0 || t2.length()==0 || t3.length()==0 || t4.length()==0 || t5.length()==0 || t6.length()==0 || t7.length()==0 || t8.length()==0 || BD.length()==0 || t10.length()==0 || t11.length()==0 || t12.length()==0 || JD.length()==0){
JOptionPane.showMessageDialog(null, "Please fill the fields or correct filled","Error", JOptionPane.ERROR_MESSAGE);
}
else{
String query3="Update Teachers set TeacherID='"+textFieldID.getText()+"', FirstName='"+textFieldFN.getText()+"', LastName='"+textFieldLN.getText()+"', CNICNO='"+textFieldCN.getText()+"', Age='"+textFieldAge.getText()+"', Salary='"+textFieldSal.getText()+"', MobileNo='"+textFieldMob.getText()+"', Gender='"+t10+"', Department='"+textFieldDep.getText()+"', Position='"+textFieldPos.getText()+"', Address='"+textFieldAdd.getText()+"', JoinDate='"+JD+"', BirthDate='"+dateChooser1.getDateFormatString()+"' where TeacherID='"+textFieldID.getText()+"' ";
PreparedStatement pst= connection.prepareStatement(query3);
int action = JOptionPane.showConfirmDialog(null, "Do you want Update this Data?","Update Confirmation",JOptionPane.YES_NO_OPTION);
if (action==0){
pst.execute();
}
JOptionPane.showMessageDialog(null, "Data Update");
pst.close();
}
}catch(SQLException e){
e.printStackTrace();
}
}
});
btnUpdateData.setBounds(399, 443, 105, 23);
contentPane.add(btnUpdateData);