title: Using a prepared statement with auto increment field
body: <p>I am trying to do insert to a table whose primary key is set to auto increment using a prepared statement. </p>
  
  <p>The fields in the table are as follows;</p>
  
  <p>id, username, password, email, firstname, last name</p>
  
  <p>My code is such that</p>
  
  <pre><code>    String sql = "INSERT INTO Users values (?,?,?,?,?, ?)";
      RegistrationStatus status = null;
      Connection conn = null;
      PreparedStatement st = null;
      try {
          conn = source.getConnection();
          st = conn.prepareStatement(sql);
          st.setString(2, username);
          st.setString(3, password);
          st.setString(4, email);
          st.setString(5, firstname);
          st.setString(6, lastname);
          st.executeUpdate();
  </code></pre>
  
  <p>Where i have read that we should no include the first item as the database will take care of it. This approach for me appears to be failing.</p>
  
  <p>Would it be possible to get some help on how to solve this?</p>