title: Why am I getting <java.sql.SQLException: ORA-00904: "PASSWORD": invalid identifier>
body: <p>This is <strong>model</strong> part of my MVC app and it is supposed to communicate with the Database(Oracle 10g XE).Here is the code that I have written,</p>
  
  <pre><code>package com.cid_org.model;
  
  import java.sql.*;
  
  public class LoginModelPOJO {
  
  private String username;
  private String password;
  private Connection connection;
  
  public LoginModelPOJO(String username, String password, Connection connection){
      this.username = username;
      this.password = password;
      this.connection = connection;
      validate();
  }
  
  private void validate(){
      try {
          String query = "SELECT * FROM CRIME_SOLVING_OFFICIAL where OFFICIAL_USERNAME=? and OFFICIAL_PASSWORD=?";
          PreparedStatement ps = connection.prepareStatement(query);
          ps.setString(1, username);
          ps.setString(2, password);
          ResultSet rs = ps.executeQuery();
          if (rs.next()) {
               // String name=rs.getString(3);
                System.out.println("success");
          } else {
              System.out.println("access denied");
          }
      } catch (Exception e) {
          System.out.println("Connection " + e);
        }
  }
  }
  </code></pre>
  
  <p>but as it gets executed, it generates the following error:</p>
  
  <pre><code>Connection java.sql.SQLException: ORA-00904: "PASSWORD": invalid identifier
  </code></pre>
  
  <p>Here is the table that I have created in Oracle,</p>
  
  <p>Here is the image <img src="https://i.stack.imgur.com/BUGGh.png" alt="enter image description here"> </p>
  
  <p>Btw, I know this question will be branded as duplicate question and indeed it is but FYI I have gone through all the available posts related to this question(You can see all the tabs opened in firefox in the picture) but couldn't find any answer.</p>
  
  <p>Edit: I have made all the 'password' strings disappear to corner out the 'PASSWORD' identifier Exception is talking about.And I have also altered the column name of the OFFICIAL_PASSWORD to OFFICIAL_PWD just to  be sure about things.</p>
  
  <p>Here is  the login.html form,</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
      &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;Criminal Investigation Department-Home&lt;/title&gt;
  
  
  &lt;link rel="stylesheet" href="css/login_page.css"&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;img src="css/images/logo/CID_Logo_1.png" alt="CID Logo"&gt;
  &lt;nav id="navigation"&gt;
      &lt;a id="link1" class="header_links" href="most_wanted.html"&gt;Most Wanted&lt;/a&gt;
      &lt;a id="link2" class="header_links" href="hotnews.html"&gt;Hot News&lt;/a&gt;
      &lt;a id="link3" class="header_links" href="report_crime.html"&gt;Report Crime&lt;/a&gt;
      &lt;a id="link4" class="header_links" href="login.html"&gt;Login&lt;/a&gt;
      &lt;a id="link5" class="header_links" href="about.html"&gt;About Us&lt;/a&gt;
      &lt;a id="link6" class="header_links" href="contact.html"&gt;Contact Us&lt;/a&gt;
      &lt;a id="link7" class="header_links" href="safety_measures.html"&gt;Safety Measures&lt;/a&gt;
  &lt;/nav&gt;
  &lt;div id="login_page_border"&gt;
      &lt;form action="LoginScript.do" method="POST"&gt;
          &lt;div id="form_border"&gt;
          &lt;span id="login_label"&gt;Login&lt;/span&gt;&lt;br&gt;
          &lt;div id="login_contents"&gt;
          &lt;span class="login_field"&gt;Username:&lt;/span&gt; &lt;input name="username" type="text"&gt;&lt;br&gt;&lt;br&gt;
          &lt;span class="login_field"&gt;Password:&lt;/span&gt; &lt;input name="pass" type="password"&gt;
          &lt;input id="login_button" type="submit" value=" "&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is the controller servlet,</p>
  
  <pre><code>package com.cid_org.controller;
  
  import java.io.IOException;
  
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import com.cid_org.model.*;
  
  import java.sql.*;
  
  /**
   * Servlet implementation class LoginControllerServlet
   */
  
  public class LoginControllerServlet extends HttpServlet {
  private static final long serialVersionUID = 1L;
  
  /**
   * @see HttpServlet#HttpServlet()
   */
  public LoginControllerServlet() {
      super();
      // TODO Auto-generated constructor stub
  }
  
  /**
   * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      // TODO Auto-generated method stub
  }
  
  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
      /*Take the data submitted by the user though the login 
       * form(Remember the HTTP Post request -&gt;HttpServletRequest request object*/
      String username = request.getParameter("username");
      String pwd = request.getParameter("pass");
      System.out.println(username + "aaa");
      System.out.println(pwd);
      Connection connection = (Connection)getServletContext().getAttribute("connection_context_param");
  
      LoginModelPOJO lmpojo = new LoginModelPOJO(username, pwd, connection);
      boolean isValidFlag = lmpojo.isValid();
  
      if(isValidFlag){
          RequestDispatcher view =request.getRequestDispatcher("view_profile.jsp");
          view.forward(request, response);
      }
      else{
          response.sendRedirect("/CrimeReportingSystem/static/login_access_denied.html");
      }
  
  }
  
  }
  </code></pre>
  
  <p>And here is a slightly modified version of the Model part,</p>
  
  <pre><code>package com.cid_org.model;
  
  import java.sql.*;
  
  public class LoginModelPOJO {
  
  private String username;
  private String pwd;
  private Connection connection;
  private boolean isValidFlag;
  
  public LoginModelPOJO(String username, String pwd, Connection connection){
      this.username = username;
      this.pwd = pwd;
      this.connection = connection;
      isValidFlag=false;
      validate();
  }
  
  private void validate(){
      try {
  
          String query = "SELECT * FROM CRIME_SOLVING_OFFICIAL where OFFICIAL_USERNAME=? and OFFICIAL_PWD=?";
          PreparedStatement ps = connection.prepareStatement(query);
          ps.setString(1, username);
          ps.setString(2, pwd);
          ResultSet rs = ps.executeQuery();
          if (rs.next()) {
               // String name=rs.getString(3);
                System.out.println("success");
                isValidFlag = true;
          } else {
              System.out.println("access denied");
          }
      } catch (Exception e) {
          System.out.println("Connection " + e);
        }
  }
  
  public boolean isValid(){
      return isValidFlag;
  }
  }
  </code></pre>
  
  <p>Finally ,here is the ContextListener,</p>
  
  <pre><code>package com.cid_org.listener;
  
  import java.sql.*;
  
  import javax.servlet.*;
  
  
  /*This listener will initialize a connection and set the context
   * attribute reference with a string at the time of application deployment time or
   * when the ServletContext will be initialized*/
  public class DatabaseServletContextListener implements ServletContextListener {
  
  Connection connection = null;
  public void contextInitialized(ServletContextEvent event) {
      ServletContext sc = event.getServletContext();
      try{
          Class.forName("oracle.jdbc.driver.OracleDriver");
          connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "java");
          System.out.println("la la la ...");
          //Set the Attribute for the connection
          sc.setAttribute("connection_context_param", connection);
      }
      catch(Exception e){
          //To be decided Later- I dislike "checked" exceptions
          System.out.println("conn...bzzz "+e);
      }
  
  }
  
  public void contextDestroyed(ServletContextEvent event) {
      try {
          /*Connection will be closed at the time of undeployment of the application or
           * when the context is destroyed*/
          connection.close();
      } catch (Exception e) {
          System.out.println("connection pika fucked " + e);
      }
  }
  
  }
  </code></pre>
  
  <p>Btw: The error is still the same.</p>