title: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver - Not Working
body: <p>I'm trying to run this program</p>
  
  <pre><code>import java.sql.*;
  import java.io.*;
  
  public class FirstExample
  {
       // JDBC driver name and database URL
      static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";  
      static final String DB_URL = "jdbc:mysql://localhost/EMP";
  
      //  Database credentials
      static final String USER = "root";
      static final String PASS = "pass";
  
      public static void main(String[] args) 
      {
          Connection conn = null;
          Statement stmt = null;
          try
              {
                  //STEP 2: Register JDBC driver
                  Class.forName("com.mysql.jdbc.Driver");
  
                  //STEP 3: Open a connection
                  System.out.println("Connecting to database...");
                  conn = DriverManager.getConnection(DB_URL,USER,PASS);
  
                  //STEP 4: Execute a query
                  System.out.println("Creating statement...");
                  stmt = conn.createStatement();
                  String sql;
                  sql = "SELECT title,duration,protocol,URL,thumbURL,favorite FROM Videos";
                  ResultSet rs = stmt.executeQuery(sql);
  
                  //STEP 5: Extract data from result set
                  while(rs.next())
                  {
                      //Retrieve by column name
                      String title = rs.getString("title");
                      String duration = rs.getString("duration");
                      String protocol = rs.getString("protocol");
                      String URL = rs.getString("URL");
                      String thumbURL = rs.getString("thumbURL");
                      String favorite = rs.getString("favorite");
  
                      //Display
                      System.out.println("Title:" + title);
                      System.out.println("Duration:" + duration);
                      System.out.println("Protocol:" + protocol);
                      System.out.println("URL:" + URL);
                      System.out.println("ThumbURL:" + thumbURL);
                      System.out.println("Favorite:" + favorite);
                  }
  
                  //STEP 6: Clean-up environment
                  rs.close();
                  stmt.close();
                  conn.close();
              }
              catch(SQLException se)
              {
                  //Handle errors for JDBC
                  se.printStackTrace();
              }
              catch(Exception e)
              {
                  //Handle errors for Class.forName
                  e.printStackTrace();
              }
              finally
              {
                  //finally block used to close resources
                  try
                  {
                      if(stmt!=null)
                      stmt.close();
                  }
                  catch(SQLException se2)
                  {
                  }// nothing we can do
                  try
                  {
                      if(conn!=null)
                      conn.close();
                  }
                  catch(SQLException se)
                  {
                      se.printStackTrace();
                  }//end finally try
              }
          System.out.println("Goodbye!");
          }
      }
  </code></pre>
  
  <p>But I'm getting the ClassNotFoundException</p>
  
  <pre><code>D:\XML Tests&gt;javac FirstExample.java
  
  D:\XML Tests&gt;java FirstExample
  java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
          at java.net.URLClassLoader$1.run(Unknown Source)
          at java.net.URLClassLoader$1.run(Unknown Source)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(Unknown Source)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at java.lang.Class.forName0(Native Method)
          at java.lang.Class.forName(Unknown Source)
          at FirstExample.main(FirstExample.java:21)
  Goodbye!
  </code></pre>
  
  <p>Having consulted the numerous question available i.e setting the PATH system variable to the Connector directory, it still isnt working.
  Any help please?</p>