title: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException - Unknown column in field list
body: <p>I am getting the following error:</p>
  
  <blockquote>
    <p>com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'userId' in 'field list' </p>
  </blockquote>
  
  <p>The code which is causing this error is this:</p>
  
  <pre><code>PreparedStatement pstmt = 
      con.prepareStatement(
          "INSERT INTO " + 
          tableName + 
          " (userId,username,email,password) VALUES (?,?,?,?)");
  </code></pre>
  
  <p>My table gets created by the following command</p>
  
  <pre><code>stmt.executeUpdate(
      "CREATE TABLE " + 
      tableName + 
      " (" + 
      " userId INT, " + 
      " userName VARCHAR(255) NOT NULL, " + 
      " email VARCHAR(255) NOT NULL, " + 
      " password VARCHAR(255), " + 
      " PRIMARY KEY(userId)" + 
      " )");
  stmt.close();
  </code></pre>
  
  <p>Can someone help me spot my mistakes if any. I am a novice in this so I am kind of struggling to find where exactly the error is.</p>