title: Why I am getting class not found exception for Class.forName("com.mysql.jdbc.Driver");
body: <p>I am developing an web app Using : eclipse IDE(Marse), Java 8, Apache tomcat 8, MySQL.
  My code for user registration is as follows:</p>
  
  <pre><code>System.out.println("Connecting....");
              Class.forName("com.mysql.jdbc.Driver");
              System.out.println("Class found....");
              String url="jdbc:mysql://localhost:3306/db";
              String user="root";
              String password="root";
              System.out.println("success");
              Connection conn = DriverManager.getConnection(url,user,password);
              String query = "insert into login (username,password,emailid,country,city) values (?,?,?,?,?)";
              PreparedStatement ps = conn.prepareStatement(query);
              ps.setString(1,b.getUsername());
              ps.setString(2,b.getPassword());
              ps.setString(3,b.getEmailid());
              ps.setString(4,b.getCountry());
              ps.setString(5,b.getCity());
              int count=ps.executeUpdate();
              ps.close();
              conn.close();
  </code></pre>
  
  <p>My code is also correct and also I <strong>added mysql-connector-java-5.1.36</strong> by using <em>Build path>add_external_jar</em> option in eclipse. But still why it gives me such a exception ?</p>
  
  <blockquote>
    <p>Connecting....
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1332)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at model.InfoModel.SaveInfo(InfoModel.java:14)
        at controller.Register_user.doGet(Register_user.java:35)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1526)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1482)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Unknown Source)</p>
  </blockquote>