こんにちは、保険ドメインの小さなアプリケーションを開発しています。プログラムで update ステートメントを使用すると、エラーが発生します。
エラーは net.ucanaccess.jdbc.UcanaccessSQLException: 予期しないトークン: HALF java.lang.NullPointerException です。
コードは
btnUpdate = new JButton("UPDATE");
btnUpdate.setMnemonic('U');
btnUpdate.setFont(new Font("Times New Roman", Font.BOLD, 11));
GridBagConstraints gbc_btnUpdate = new GridBagConstraints();
gbc_btnUpdate.insets = new Insets(0, 0, 5, 5);
gbc_btnUpdate.gridx = 3;
gbc_btnUpdate.gridy = 3;
contentPane.add(btnUpdate, gbc_btnUpdate);
btnUpdate.setVisible(false);
btnUpdate.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
Statement stmt = null;
ResultSet rset = null;
Calendar currcal = Calendar.getInstance();
SimpleDateFormat df;
df = new SimpleDateFormat("dd-MM-yyyy");
Date getcurrdate = currcal.getTime();
String currdate = df.format(getcurrdate);
System.out.println(getModeID + "," + getModeofPaymentDescription + "," + getModeofPaymentType + "," + currdate);
try {
getModeofPaymentDescription=txt_Mode_Of_Payment_Description.getText().toUpperCase();
getModeofPaymentType=txt_Mode_Of_Payment_Type.getText().toUpperCase();
stmt = dbcon.DB_Connection("//F://eclipse_Luna_64_Development_Workspace//ProjectJAVA//LIC_AGENCY_TRACKER//DATABASE//LIC_DATA_TRACKER.accdb").createStatement();
stmt.executeUpdate("update Mode_Of_Payment_Profile set Mode_Of_Payment_Profile_Type='" + getModeofPaymentType + "'"
+ "',Mode_Of_Payment_Profile_Description='" + getModeofPaymentDescription + "',Mode_Of_Payment_Profile_Creation_Date='" + currdate + "'"
+ " where Mode_Of_Payment_Profile_ID='" + getModeID + "'");
} catch (Exception e) {
//JOptionPane.showMessageDialog(null, "Database Error", "Error Message", JOptionPane.OK_OPTION);
System.out.println(e);
}
txt_Mode_Of_Payment_Description.setText("");
txt_Mode_Of_Payment_Type.setText("");
btnAdd.setEnabled(true);
btnModify.setVisible(true);
btnUpdate.setVisible(false);
txt_Mode_Of_Payment_Description.requestFocus();
try {
stmt.close();
rset.close();
dbcon.DB_Connection("//F://eclipse_Luna_64_Development_Workspace//Project JAVA//LIC_AGENCY_TRACKER//DATABASE//LIC_DATA_TRACKER.accdb").close();
} catch (Exception e) {
System.out.println(e);
}
}
});