title: Escaping reserved words in MySQL: Unknown column 'PASSWORD' in 'field list'
body: <p>My problem is with regards to JDBC SQL. What i want to do is use my username in the employee entity to retrieve the password for my login. I have a datainitalization singleton bean to prepopulate my system admin. </p>
  
  <p>Error Message in GlassFish.</p>
  
  <pre><code>Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.1.v20150605-
  31e8258): org.eclipse.persistence.exceptions.DatabaseException
  Internal Exception: 
  com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 
  'PASSWORD' in 'field list'
  Error Code: 1054
  Call: SELECT EMPLOYEEID, ACCESSRIGHT, ADDRESSLINE1, ADDRESSLINE2, 
  CONTACTNUMBER, FIRSTNAME, LASTNAME, PASSWORD, POSTALCODE, USERNAME FROM 
  EMPLOYEE WHERE USERNAME LIKE ?
  bind =&gt; [1 parameter bound]
  Query: ReadAllQuery(referenceClass=Employee sql="SELECT EMPLOYEEID, 
  ACCESSRIGHT, ADDRESSLINE1, ADDRESSLINE2, CONTACTNUMBER, FIRSTNAME, LASTNAME, 
  PASSWORD, POSTALCODE, USERNAME FROM EMPLOYEE WHERE USERNAME LIKE ?")
  </code></pre>
  
  <p>My method to retrieve password for login using username</p>
  
  <pre><code>    @Override
  public Employee retrievePasswordByUsername(String username) throws UserNameNotFoundException
  {
      //SELECT sl FROM SystemLogin sl WHERE sl.userName  = :inUserName
     return (Employee) em.createQuery("SELECT e FROM Employee e WHERE e.username LIKE :inUsername").setParameter("inUsername", username).getResultList();
  
  }
  </code></pre>
  
  <p>This is my attempt to do a login method.</p>
  
  <pre><code>@Override
  public Employee employeeLogin(String username, String password) throws 
  InvalidLoginCredentialException
  {
  
  
      Employee employee = null;
      try {
          employee = retrievePasswordByUsername(username);
      } catch (UserNameNotFoundException ex) {
          Logger.getLogger(EmployeeController.class.getName()).log(Level.SEVERE, null, ex);
      }
  
       if(employee.getPassword().equals(password))
          {
              return employee;
          }
          else
          {
              throw new InvalidLoginCredentialException("Username does not exist or invalid password!");
          }
      }
  </code></pre>
  
  <p>Lastly, this is the singleton bean that i mention for my system admin</p>
  
  <pre><code>     private void initializeData()
      {
          try {
              employeeControllerLocal.createNewEmployee(new Employee("Default", 
      "Administrator", "99999999", "NUS", "Computing","599999", 
      EmployeeAccessRight.ADMINISTRATOR, "admin", "password"));
          } catch (EmployeeExistException ex) {
  
  
   Logger.getLogger(DataInitializationSessionBean.class.getName()).log(Level.SEVERE
          , null, ex);
          } catch (GeneralException ex) {
  
    Logger.getLogger(DataInitializationSessionBean.class.getName()).log(Level.SEVERE, null, ex);
          }
  
      }
  </code></pre>
  
  <p>This is part of my employee entity class.</p>
  
  <pre><code>private static final long serialVersionUID = 1L;
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long employeeId;
  @Column(length = 32, nullable = false)
  private String firstName;
  @Column(length = 32, nullable = false)
  private String lastName;
  @Column(length = 32, nullable = false)
  private String contactNumber;
  @Column(length = 32, nullable = false)
  private String addressLine1;
  @Column(length = 32, nullable = false)
  private String addressLine2;
  @Column(length = 32, nullable = false)
  private String postalCode;
  @Column(nullable = false)
  @Enumerated(EnumType.STRING)
  private EmployeeAccessRight accessRight;
  @Column(unique = true)
  private String username;
  @Column(length = 32, nullable = false)
  private String password;
  </code></pre>
  
  <p>Thanks everyone for reading this! Hope i'll find a solution soon. :)</p>
  
  <p>PS: This question has been solved. I've also posted one link for anyone who needs to check if they need to escape any reserved words:
  <a href="https://dev.mysql.com/doc/refman/5.7/en/keywords.html" rel="nofollow noreferrer">https://dev.mysql.com/doc/refman/5.7/en/keywords.html</a></p>