title: Error : Index parameter out of range
body: <p>I want to insert primary key of selected item of combo box </p>
  
  <p>but I got this error <code>Parameter index out of range(12 &gt; number of parameter which is 0)</code>".</p>
  
  <p>I really don't know how to fix this.</p>
  
  <p><strong>Here is my code:</strong></p>
  
  <pre><code>String valueTrainer = "kosong";
  try
  {
     String sql2 = "Insert into ahli (MemberID, TrainerID, Name, ICNumber, Address, Nationality,"
                          + "PhoneNumber, Email, EmergencyPerson, EmergencyContact, DateReg, MemberTypeID) "
                          + "values(?,?,?,?,?,?,?,?,?,?,?,?)";
  
  
                  pst = conn.prepareStatement(sql2);
  
                  pst.setString(1, MemberIDTextField.getText());
                  pst.setString(2, valueTrainer);
                  pst.setString(3, NameTextField.getText());
                  pst.setString(4, jTextField1.getText());
                  pst.setString(5, AddressTextArea.getText());
  
                  //Nationality combo box
                  String nationalityList = NationalityComboBox.getSelectedItem().toString();
                  pst.setString(6, nationalityList);
  
                  pst.setString(7, PhoneNumberTextField.getText());
                  pst.setString(8, EmailTextField.getText());
                  pst.setString(9, EmerContactPersonTextField.getText());
                  pst.setString(10, EmerContactNumberTextField.getText());
  
                  //Date Chooser
                  pst.setString(11, ((JTextField)MemberDateChooser.getDateEditor().getUiComponent()).getText());
  
                  //membertype combobox
                  // problem start from here, I think..
                  String memberTypeList = MemberTypeComboBox.getSelectedItem().toString();
                  String sql1  ="Select MemberTypeID from jeniskeahlian where Type = '"+memberTypeList+"' " ;
                  pst = conn.prepareStatement(sql1);
  
                  rs = pst.executeQuery();
  
                  while(rs.next()){
  
                      String memberType = rs.getString("MemberTypeID");
                      pst.setString(12, memberType);
  
                 }
  
                  pst.execute();
  
                  JOptionPane.showMessageDialog(null, "New member has been added");
  
              } catch (SQLException | HeadlessException e) {
                  JOptionPane.showMessageDialog(null, e);
              }
  </code></pre>