title: Parameter index out of range (1 > number of parameters, which is 0). output when attempting to save information to database
body: <p>I created a small program where the user must input data into text fields and select options from combo boxes. I created a database using XAMPP and created the corresponding tables for the program through the web browser.</p>
  
  <p>The database is called <strong>activitydb</strong> and the table that's responsible for storing the data from the program is called <strong>userdata</strong>.</p>
  
  <p>The first column in the table is called <strong>UserID</strong> and is an int that auto increments every time a new entry is added.
  The rest are all varchars with varying maximum lengths.</p>
  
  <p>This is currently the source code of the program:</p>
  
  <pre><code>Connection con = null;
  Statement st = null;
  try {
      // activitydb = database name
      con = DriverManager.getConnection("jdbc:mysql://localhost:3306/activitydb?zeroDateTimeBehavior=convertToNull", "root", "");
      st = con.createStatement();
      // userdata = table name
      String sqlconn = "INSERT INTO userdata (UserID, LastName, FirstName, MiddleName, Email, Sex, HomeAddress, City, CPUBrand, ComputerType, HardwareSpecs, GPUBrand, GPUType, GPUVRAM)";
      PreparedStatement prdStmt = con.prepareStatement(sqlconn);
      // Input of variable data into corresponding database table
      // First table will be declared as null as it is an Integer designed with an Auto Increment
      prdStmt.setString(1, null);
      prdStmt.setString(2, jTextLastName.getText());
      prdStmt.setString(3, jTextFirstName.getText());
      prdStmt.setString(4, jTextMiddleName.getText());
      prdStmt.setString(5, jTextEmail.getText());
      prdStmt.setString(6, jComboBoxSex.getSelectedItem().toString());
      prdStmt.setString(7, jTextHomeAddress.getText());
      prdStmt.setString(8, jTextCity.getText());
      prdStmt.setString(9, jComboBoxCPUBrand.getSelectedItem().toString());
      prdStmt.setString(10, jComboBoxComputerType.getSelectedItem().toString());
      prdStmt.setString(11, jComboBoxHardwareSpecs.getSelectedItem().toString());
      prdStmt.setString(12, jComboBoxGPUBrand.getSelectedItem().toString());
      prdStmt.setString(13, jComboBoxGPUType.getSelectedItem().toString());
      prdStmt.setString(14, jComboBoxGPUVRAM.getSelectedItem().toString());
      // Do this if something goes wrong
  } catch (SQLException err) {
      // Print error message to console for diagnosis
      System.out.println(err.getMessage());
  }
  </code></pre>
  
  <p>For the combo boxes, I've used <code>getSelectedItem().toString()</code> to have the data found inside stored as a String.</p>
  
  <p>Clicking the button will make the program do nothing but print this in the console:
  <code>Parameter index out of range (1 &gt; number of parameters, which is 0).</code></p>