title: Error: com.microsoft.sqlserver.jdbc.SQLServerException: The index 2 is out of range
body: <pre><code>I have a function to update the user's information as follows:
  
  public void updateAccount(String username, String name, String address, String aboutMe, String 
  id) {
      String sql = &quot;update Account set username = '?', \n&quot;
              + &quot;                [Full_Name] = '?',\n&quot;
              + &quot;                [Address] = '?',\n&quot;
              + &quot;                [about_me] = '?'\n&quot;
              + &quot;                where id = ?&quot;;
      try {
          PreparedStatement ps = connection.prepareStatement(sql);
          ps.setString(1, username);
          ps.setString(2, name);
          ps.setString(3, address);
          ps.setString(4, aboutMe);
          ps.setString(5, id);
          ps.executeUpdate();
  
      } catch (Exception ex) {
          Logger.getLogger(AccountDao.class.getName()).log(Level.SEVERE, null, ex);
      }
  }
  
  and this code is giving me an error like this: 
  
  Severe: com.microsoft.sqlserver.jdbc.SQLServerException: The index 2 is out of range.
  </code></pre>
  <p>at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:191)
  at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setterGetParam(SQLServerPreparedStatement.java:933)
  at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setValue(SQLServerPreparedStatement.java:948)
  at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setString(SQLServerPreparedStatement.java:1578)
  at dao.AccountDao.updateAccount(AccountDao.java:117)
  at controller.UserProfileController.doPost(UserProfileController.java:91)</p>
  <p><strong>I don't understand why it gives me the error &quot;The index 2 is out of range&quot; and is there any
  way to fix it?</strong></p>