title: Java / SQL: MySQLSyntaxErrorException: Unknown column 'username' in 'where clause'
body: <p>I am stuck with the following code, and I don't see why I get an exception. </p>
  
  <p>The string runs fine when I put it into the SQL field of phpMyAdmin.</p>
  
  <p>And I receive a table as I expect, namely the table cid with 1 value, the playerID.</p>
  
  <p>I also used this code in variations where I say <code>"WHERE playerID = " +playerID</code> and that works....</p>
  
  <p>So am really excited why this does not work when I run it through eclipse. </p>
  
  <p>Yes, I did search here, found a lot of similar MySQLSyntaxErrorException threads but none did lead me to a solution</p>
  
  <pre><code>public int getUserIDfromDBcoolpag(String inputUsername){
      System.out.println("getUserIDfromDBcoolpag called");
      int playerID = 0;
          try {
              SQLConnection.getInstance().init(DATABASE_HOST, DATABASE_PORT, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD);
              Connection connection = SQLConnection.getInstance().getConnection();
              try
              {
                  String getPlayerID = "SELECT coolpag.player.id as cid FROM coolpag.player WHERE username=" +inputUsername;
                  PreparedStatement statement = connection.prepareStatement(getPlayerID);
                  try
                  {
                      ResultSet res = statement.executeQuery();
                      try
                      {
                          while (res.next())
                          {
                              playerID = res.getInt("cid");
                          }
  //                      System.out.println("LOG: output operation finished");
                      }
                      finally
                      {
                          res.close();
                      }
                  }
                  finally
                  {
                      statement.close();
                  }
              }
              finally
              {
              }
  
              boolean isAlive = SQLConnection.getInstance().getConnection().isClosed();
              if(isAlive){
                  System.out.println("Connection is not yet closed");
              }
          } catch (NullPointerException e) {
              e.printStackTrace();
          } catch (ClassNotFoundException e) {
              e.printStackTrace();
          } catch (SQLException e) {
              e.printStackTrace();
          }
          return playerID;
      }
  </code></pre>