I just want to ask what I can do or a solution to this problem? [enter image description here]` private void update_buttonActionPerformed(java.awt.event.ActionEvent evt) {
try{
String StudId = Id_field.getText();
String Lastname = lastname_field.getText();
String Firstname = firstname_field.getText();
String Middle_Ini = MiddleInitial_field.getText();
String Age = age_field.getText();
String Section = section_field.getText();
String Address = address_field.getText();
String Contact = contact_field.getText();
Class.forName("com.mysql.cj.jdbc.Driver");
sqlConn = DriverManager.getConnection(dataConn, username,password);
String update ="UPDATE user_information SET ID=?, Lastname=?, Firstname=?, MiddleInitial=?, "
+ "Age=?, Section=?, Address=?, ContactNo=? WHERE primary_Id=?";
pst = sqlConn.prepareStatement(update);
pst.setString(1, StudId);
pst.setString(2, Lastname);
pst.setString(3, Firstname);
pst.setString(4, Middle_Ini);
pst.setString(5, Age);
pst.setString(6, Section);
pst.setString(7, Address);
pst.setString(8, Contact);
if (pst.executeUpdate() != -1) {
UpdateDb();
JOptionPane.showMessageDialog(this, "Record Updated");
}
}//try
catch(ClassNotFoundException ex){
java.util.logging.Logger.getLogger(record_book.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}catch(Exception e){
System.out.print(e);
}
}
There are 9 question marks (
?) in your prepared statement, and you need to provide a value for all of them. So, either remove the 9th question mark, or provide a value for it: