title: ClassNotFoundException when trying to connect with mysql dbms?
body: <p>I have seen many solutions in this site relating the same problem that I am facing now, I rectified my project structure also but still no success, </p>
  
  <p><strong>First</strong> attempt I placed mysqlconnector.jar in <strong>WEB-INF/lib</strong> -> GOT ERROR. 
  <strong>Second</strong>, I removed it from lib folder, and added as external jar in build path -> GOT ERROR. 
  Also I tried both above ways after placing mysqlconnector jar file in <strong>jre8/lib/ext</strong>  -> NO SUCCESS!</p>
  
  <p>Please ignore any small or irrelevant modifications, I just needed to check the connectivity thats all. I have JRE8 and Tomcat8 server running, which I believe is not an issue in this.</p>
  
  <p>Here is a simple code of connectivity I just want to check if it is establishing a connection or not, that is why I haven't coded any further.</p>
  
  <pre><code>public class MySQLConnection {
  
      public static final String DRIVER_CLASS = "com.mysql.jdbc.Driver"; 
      public static final String URL = "jdbc:mysql://localhost:3306/payinguest";
      public static final String USER = "root";
      public static final String PASSWORD = "root";
  
  
      public MySQLConnection() {
          try {
              Class.forName(DRIVER_CLASS);
          } catch (ClassNotFoundException e) {
              e.printStackTrace();
          }
      }
    }
  </code></pre>
  
  <p>My index.jsp is </p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8" import="com.pg.dao.MySQLConnection"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;% MySQLConnection db = new MySQLConnection();%&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
          at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1324)
          at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1177)
          at java.lang.Class.forName0(Native Method)
          at java.lang.Class.forName(Unknown Source)
          at com.pg.dao.JDBCMySQLConnection.&lt;init&gt;(JDBCMySQLConnection.java:15)
          at org.apache.jsp.index_jsp._jspService(index_jsp.java:71)
  </code></pre>