title: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 11
body: <p>Thank you Alexandre but now I keep receiving the following error: </p>
  
  <p>java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Number of query values and destination fields are not the same.</p>
  
  <p>But I have 11 question marks and 11 parameters so I don't understand this error either.</p>
  
  <pre><code>PreparedStatement stmt = conn.prepareStatement("INSERT INTO STAFFDIR VALUES (?,?,?,?,?,?,?,?,?,?,?)");
  stmt.setString(1, LN);
  stmt.setString(2, FN);
  stmt.setString(3, M);
  stmt.setString(4, Phone);
  stmt.setInt(5, DC);
  stmt.setString(6, Email);
  stmt.setInt(7, FC);
  stmt.setString(8, Title);
  stmt.setInt(9, LC);
  stmt.setString(10, Picture);
  stmt.setString(11, PC);
  stmt.executeUpdate(); 
  </code></pre>
  
  <p>------------------ Original message----------------------</p>
  
  <p>The code below generates the following error. Why? This is an MS Access 2010 .accdb database. The table in question does have another field called ID
  which is defined as a primary key. But I didn't think that I would need to reference it in any way though. Do I? Any and all help is appreciated, thanks. </p>
  
  <pre><code>[5/8/14 10:06:34:986 EDT] 00000025 SystemOut     O First Name = John
  [5/8/14 10:06:34:986 EDT] 00000025 SystemOut     O Last Name = Doe
  [5/8/14 10:06:34:986 EDT] 00000025 SystemOut     O Middle = M
  [5/8/14 10:06:34:986 EDT] 00000025 SystemOut     O Phone = 212 999-9999
  [5/8/14 10:06:34:986 EDT] 00000025 SystemOut     O DeptCode = 0
  [5/8/14 10:06:34:986 EDT] 00000025 SystemOut     O Email = nbroat@msn.com
  [5/8/14 10:06:34:986 EDT] 00000025 SystemOut     O Title = None
  [5/8/14 10:06:34:986 EDT] 00000025 SystemOut     O FaxCode = 2
  [5/8/14 10:06:34:986 EDT] 00000025 SystemOut     O LocCode = 1
  [5/8/14 10:06:34:986 EDT] 00000025 SystemOut     O Picture = none
  [5/8/14 10:06:34:986 EDT] 00000025 SystemOut     O Pic_Code = N
  [5/8/14 10:06:35:047 EDT] 00000025 SystemOut     O Error occurred     java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 11.
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 11.
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6969)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7126)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:3161)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(JdbcOdbcPreparedStatement.java:228)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeQuery(JdbcOdbcPreparedStatement.java:103)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at cophonebk.COaddstaff.performTask(COaddstaff.java:104)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at cophonebk.COaddstaff.doPost(COaddstaff.java:39)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1663)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:939)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3944)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at  com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)  
  [5/8/14 10:06:35:047 EDT] 00000025 SystemErr     R  at    com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1646)  
  
  
          Connection conn = null;
          ResultSet result = null;
          PreparedStatement stmt = null;
  
          String LN = (String)request.getParameter("Last_Name");          
      String FN = (String)request.getParameter("First_Name");
      String M  = (String)request.getParameter("Middle");
      String Ph = (String)request.getParameter("Phone");
  
          String Dept_Code = (String)request.getParameter("Dept_Code");
          Integer DC = Integer.valueOf(Dept_Code);
  
      String E = (String)request.getParameter("Email");
      String Fax_Code = (String)request.getParameter("Fax_Code"); 
      Integer FC = Integer.valueOf(Fax_Code);
  
      String T = (String)request.getParameter("Title");
  
      String Loc_Code = (String)request.getParameter("Loc_Code");
      Integer LC = Integer.valueOf(Loc_Code);
  
      String Pic = (String)request.getParameter("Picture");
      String PC = (String)request.getParameter("Pic_Code");
  
      System.out.println("First Name = " + FN);
      System.out.println("Last Name = " + LN);
      System.out.println("Middle = " + M);
      System.out.println("Phone = " + Ph);
          System.out.println("DeptCode = " + DC);
          System.out.println("Email = " + E);
          System.out.println("Title = " + T);
          System.out.println("FaxCode = " + FC);
          System.out.println("LocCode = " + LC);
          System.out.println("Picture = " + Pic);
          System.out.println("Pic_Code = " + PC);
  
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          conn = DriverManager.getConnection("jdbc:odbc:CentralOfficePhoneDirectory");
  
          try {
              stmt = conn.prepareStatement("INSERT INTO STAFFDIR(Last_Name,First_Name,Middle,Phone,Dept_Code,Email,Title,Fax_Code,Loc_Code,Picture,Pic_Code) VALUES(LN,FN,M,Ph,DC,E,T,FC,LC,Pic,PC)");
              result = stmt.executeQuery();
  
              try {
                  stmt.close();
              }  catch (SQLException e) {
             e.printStackTrace();
          }
          try {
                  conn.close();
          }   catch (SQLException e) {
                  e.printStackTrace();
          }           
              return;
          } // End of try
  
          catch (SQLException e) {
                System.out.println("Error occurred " + e);
                e.printStackTrace();
                return;
          }
  </code></pre>