I am trying to insert the following data, but when I press the save button the following error is displayed: java.sql.SQLException:[SQLITE_ERROR] SQL error or missing database (near “ID”:syntax error)
Thanks for the help=)
JButton btnSave = new JButton("Save");
btnSave.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
String query="INSERT INTO PatientInfo (Patient ID, First Name, Last Name, Date of Birth, Address, Emergency Phone Number, Medical Condition, Appointments, Milling, Comments) values (?,?,?,?,?,?,?,?,?,?)";
preparedstatement=connection.prepareStatement(query);
preparedstatement.setString(1, patientIDtextField.getText());
preparedstatement.setString(2, firstNametextField.getText());
preparedstatement.setString(3, lastNametextField.getText());
preparedstatement.setString(4, dobtextField.getText());
preparedstatement.setString(5, addresstextField.getText());
preparedstatement.setString(6, EPNtextField.getText());
preparedstatement.setString(7, MedicalContextField.getText());
preparedstatement.setString(8,ApptextField.getText());
preparedstatement.setString(9, BillingtextField.getText());
preparedstatement.setString(10, CommentstextField.getText());
preparedstatement.executeQuery();
JOptionPane.showMessageDialog(null, "Data Saved");
} catch (Exception e1) {
JOptionPane.showMessageDialog(null, e1);
}
finally{
try{
preparedstatement.close();
}
catch(Exception e1){
JOptionPane.showMessageDialog(null, e1);
}
}
}
});
Aucun commentaire:
Enregistrer un commentaire