title: Is there a limit to PreparedStatement variables or requirements for their placement?
body: <p>Is there a limit to PreparedStatement variables (?) or requirements for their placement?</p>
  
  <p>I have a method that takes in the parameters to complete a PreparedStatement however, it throws a SQLException.</p>
  
  <p>Here is the PreparedStatement I want to use:</p>
  
  <pre><code>String update = "UPDATE ? SET ? = ? WHERE UserID = ?";
  </code></pre>
  
  <p>When I add in the first and second variables it runs just fine. Here is the working PreparedStatement:</p>
  
  <pre><code>String update = "UPDATE Student SET First_Name = ? WHERE UserID = ?";
  </code></pre>
  
  <p>Is there a reason I cannot get the first statement to work?</p>
  
  <p><br>
  The entire method:</p>
  
  <pre><code>public static void runUpdate(String givenID, String givenAttribute, String givenUpdate) throws SQLException
  {
      // Establish the connection with the database
      Connection conn = SimpleDataSource.getConnection();
      try
      {
          // Create a string with the SQL Update statement                       
          String update = "UPDATE ? SET ? = ? WHERE UserID = ?";
  
          // Make a Prepared Statement with the connection to the database
          PreparedStatement stat = conn.prepareStatement(update);
          try
          {
              // Set the statement with the given parameters
              stat.setString(1, Utility.getType(givenID));
              stat.setString(2, givenAttribute);
              stat.setString(2, givenUpdate);
              stat.setString(3, givenID);
              // Execute the Update Statement
              stat.executeUpdate();
          }
          finally
          {
              // Close the prepared Statement
              stat.close();
          }
      }
      finally
      {
          // Close the connection to the database
          conn.close();
      }
  }
  </code></pre>