java.lang.ClassNotFoundException: com.mysql.jdbc.Driver - Not Working -


This question is already an answer here

  • 6 replies

    I run Trying this program

      import java.sql. *; Import java.io * *; Public Class First Example {// JDBC Driver's Name and Database URL Fixed Last String JDBC_DRIVER = "com.mysql.jdbc.Driver"; Fixed final string DB_URL = "jdbc: mysql: // localhost / emp"; // database credential static last string USER = "root"; Fixed last string PASS = "pass"; Public static zero main (string [] args) {connection conn = null; Description stmt = null; Try {// STEP 2: Register JDBC Driver Class. ForName ("com.mysql.jdbc.Driver"); // STEP 3: Open a connection System.out.println ("Connecting to the database ..."); Conn = DriverManager.getConnection (DB_URL, USER, PASS); // STEP 4: Perform a query system. Out.println ("Creating Statements ..."); Stmt = conn.createStatement (); String sql; Sql = "Select Title, Duration, Protocol, URL, Thumb URL, Favorites from Video"; Results set rs = stmt.executeQuery (SQL); // STEP 5: Remove the data from the result set (rs.next ()) {// Column renamed by string title = rs.getString ("title"); String Period = rs.getString ("Period"); String protocol = rs.getString ("protocol"); String url = rjest string ("url"); String thumbURL = rs.getString ("thumbURL"); String Prefix = R.getString ("Favorites"); // Display System.out.println ("title:" + title); System.out.println ("Duration:" + Duration); System.out.println ("Protocol:" + Protocol); System.out.println ("url:" + url); System.out.println ("Thumb URL:" + Thumb URL); System.out.println ("Favorites:" + Favorites); } // Step 6: clean up environment (rsclose); Stmt.close (); Conn.close (); } Hold (from eclipsection) {// handle errors for JDBC se.printStackTrace (); } Hold (Exception E) {// Handle Errors for Class e.printStackTrace (); } Finally {// Finally try the block used to close resources {if (stmt! = Null) stmt.close (); } Hold (SQLException se2) {} // nothing can we try {if (conn! = Null) conn.close (); } Grip (from eclipsection) {se.printStackTrace (); } // Finally try} System.out.println ("Bye!"); }}   

    But I'm getting ClassNotFoundException

      D: \ XML Test & gt; Javac FirstExample.java D: \ XML Test & gt; Java FirstExample Java Lang.ClassNotFoundException: java.net.URLClassLoader $ 1.run (unknown source) java.security.AccessController.doPrivileged (native resident method) at java.net.URLClassLoader at $ 1.run (unknown source) com.mysql Jdbc.Driver java.net.URLClassLoader.findClass (Unknown Source) java.lang.ClassLoader.loadClass at sun.misc.Launcher $ AppClassLoader.loadClass at java.lang.ClassLoader.loadClass (unknown source) (unknown source) ) At java.lang.Class.forName0 at java.lang.Class.forName (Native Method) (unknown source) FirstExample.main (FirstExample.java:21) bye bye!   

    After consulting the many questions available to set the Path System variable in the connector directory, it still does not work. Any help please?

    Driver in the class path

    Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -