title: You have an error in your SQL syntax (...) near ;
body: <p>I got this message, and I couldn't find any error:</p>
  
  <blockquote>
    <p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where id ='null'' at line 1</p>
  </blockquote>
  
  <p>I assumed this code was wrong, but it turned out it isn't.</p>
  
  <pre><code>ResultSet rs = stmt.executeQuery("select password" +
                                   "from userinfo where id = '" + id + "';"); 
  </code></pre>
  
  <p>This is full code of error file.</p>
  
  <pre><code> private boolean checkLoginInfo(String id, String password) throws ServletException
   {
          Connection conn = null;
          Statement stmt = null;
  
          try
          {
              Class.forName("com.mysql.jdbc.Driver");
              conn = DriverManager.getConnection(
                  "jdbc:mysql://localhost:3306/webdb", "root", "1234");
              if (conn == null)
                  throw new Exception("can't connect to database.&lt;BR&gt;");
              stmt = conn.createStatement();
              ResultSet rs = stmt.executeQuery("select password" +
                                              " from userinfo where id = '" + id + "';"); 
                  if (!rs.next()) 
                     return false;
                  String correctPassword = rs.getString("password");
                  if (password.equals(correctPassword))
                      return true;
                  else
                      return false;
          }
  </code></pre>