title: runtime error: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
body: <p>I am new to mysql and jdbc and I am getting the error in this title. I have been searching all day and cannot find a solution that works for me. </p>
  
  <p>What I have tried:
  uninstall/reinstall mysql, copy paste mysql-connector-java-5.1.25-bin.jar and ojdbc7.jar to same location as the .class file I am trying to run, rebuilt the program in a different directory, and probably a couple other things. </p>
  
  <p>I am using notepad++ for coding and the windows command prompt to compile and run. it compiles fine but I try to run with</p>
  
  <blockquote>
    <p>C:\Projects\bin>java -cp . ClientBase</p>
  </blockquote>
  
  <p>The output is:</p>
  
  <blockquote>
    <p>java.lang.ClassnNotFoundException: com.mysql.jdbc.Driver <br> </p>
    
    <blockquote>
      <p>at java.net.URLClassloader$1.run(URLClassLoader.java:336) <br>
      at java.net.URLClassLoader$1.run(URLClassLoader.java:355) <br>
      at java.security.AccessController.doPrivileged(Native Method) <br>
      at java.net.URLClassLoader.findClass(URLClassLoader.java:354) <br>
      at java.lang.ClassLoader.loadClass(ClassLoader.java:432) <br>
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) <br>
      at java.lang.ClassLoader.loadClass(ClassLoader.java:356) <br>
      at java.lang.Class.forName0(Native Method) <br>
      at java.lang.Class.forName(Class.java:188) <br>
      at ClientBase.main(ClientBase.java:21) <br>
      Goodbye.</p>
    </blockquote>
  </blockquote>
  
  <pre><code>// import packages
  import java.sql.*;
  
  // create class ClientBase
  public class ClientBase{
              // JDBC driver name and database URL
              static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";                
              static final String DB_URL = "jdbc:mysql://localhost/CLIENTBASE";          
  
  
  
   // Database credentials
      static final String USER = "root";
      static final String PASS = "";
  
  // Begin method main
  public static void main(String[] args) {
      Connection conn = null;
      Statement stmt = null;
  
      try{
          // register JDBC driver
          Class.forName("com.mysql.jdbc.Driver");
  
          // Open connection
          System.out.println("Connecting to database...");
          conn = DriverManager.getConnection(DB_URL, USER, PASS);
  
          // Execute a query
          System.out.println("Creating statement...");
          stmt = conn.createStatement();
          String sql;
          sql = "SELECT id, name, address, address 2, city, phone, state, zip, fax FROM CLIENTBASE";
          ResultSet rs = stmt.executeQuery(sql);
  
          // Extract data from result set
          while(rs.next()){
              // Retrieve by column name
              int id = rs.getInt("id");
              String name = rs.getString("name");
              String address = rs.getString("address");
              String address2 = rs.getString("address2");
              String city = rs.getString("city");
              String phone = rs.getString("phone");
              String state = rs.getString("state");
              String zip = rs.getString("zip");
              String fax = rs.getString("fax");
  
              // Display values
              System.out.print("ID: " + id);
              System.out.print(" Name: " + name);
              System.out.println("Address:" + address);
              System.out.println(address2);
              System.out.print("City:" + city);
              System.out.print(" State: " + state);
              System.out.println(" Zip: " + zip);
              System.out.print("Phone: " + phone);
              System.out.println(" Fax: " + fax);
          } // end while
  
          // clean up
          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 se){
              se.printStackTrace();
          } // end finally
      } // end try
  System.out.println("Goodbye.");
  } // End method main
  } // end class ClientBase
  </code></pre>
  
  <p>I should also say that I am going off an online tutorial for this code. It is not exactly how they have it as I decided to make something a little different than theirs, but it is generally the same. I don't think it is a code problem though from what the error is. </p>
  
  <p>Any help would be appreciated! I'm going crazy!</p>