I have my project which is a driver's license data base.
When the user dill out the fields, it is normal, but when the user pressed the 'Submit' button, everything is messed up.
The error Parameter index out of range error is shown, so here's my code.
private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {
String sql = "INSERT INTO dr_record_table (Driver's ID, Last Name, First Name, Middle Name, Street, Barangay, City/Municipality, Province, Country, Month, Day, Year, Gender) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
try {
pst = conn.prepareStatement(sql);
pst.setString(1, idTxtFld.getText());
pst.setString(2, lnTxtFld.getText());
pst.setString(3, fnTxtFld.getText());
pst.setString(4, mnTxtFld.getText());
pst.setString(5, saTxtFld.getText());
pst.setString(6, baTxtFld.getText());
pst.setString(7, caTxtFld.getText());
pst.setString(8, paTxtFld.getText());
pst.setString(9, cntryTxtFld.getText());
pst.setString(10, String.valueOf(monthCBox.getSelectedItem()));
pst.setString(11, String.valueOf(dayCBox.getSelectedItem()));
pst.setString(12, String.valueOf(yearCBox.getSelectedItem()));
pst.setString(13, getSelectedButtonText(bg));
pst.execute();
JOptionPane.showMessageDialog(null, "Entry Saved!");
} catch (SQLException | HeadlessException e) {
JOptionPane.showMessageDialog(null, e);
}
}