jdbc - java connectivity with mysql error -


I just started with connectivity and tried this example. I have installed the necessary software and also the jar file was copied to the / ext folder. The following error is in the code below

  import java.sql. *; Public class Jdbc00 {public static zero main (string terms []) {try {statement stmt; Class.forName ("com.mysql.jdbc.Driver"); String url = "JDBC: mysql: // local host: 3306 / mysql" DriverManager.getConnection (url, "root", "root"); // display URL and connection information System.out.println ("url:" + url); System.out.println ("Connection:" + Con?); // Get a statement object stmt = con.createStatement (); // Create new database stmt.executeUpdate ("Create database database"); Select stmt.executeUpdate ( "GRANT, Insert, Update, Delete," + "to create, drop, identified with 'Drowssap" by "+", "" JunkDB *' AUSER '@' localhost on ' for."); Con.close (); } Hold (exception e) {e.printStackTrace (); } // end hold} // main end} // end square Jdbc00  

but this error is

  given D: \ Java12 \ Explore & gt; ; Java Jdbc00 java.lang.ClassNotFoundException: java.net.URLClassLoader $ 1.run (Unknown Source) java.security.AccessController.doPrivileged (Native Method) at com.mysql.jdbc.Driver java.net.URLClassLoader.findClass on (unknown source) at JavaklangkClassLoaderkloadClass (unknown source) at sun.misc.Launcher $ AppClassLoader.loadClass (unknown source) (unknown source java.lang.ClassLoader.loadClass) on java.lang.Class.forName0 (original Jdbc00.main (jdbc00.java11) on JavaklangkClasskforName (unknown source) method on)  

what is there I can guide you to the right?

The JAR file that contains the MySQL driver class ( com.mysql.jdbc. Driver ) Not responding when you run on your classpath while running your application. ClassNotFoundException is complaining about it.

You must add it to the CLASSPATH environment variable or classpath option, for example Java is running:

  java-cp mysql-connector-java-5.0.8-bin.jar jdbc00  

whatever the use of the name of the MySQL connector and place the jar file that you use are (you already have locally MySQL is not installed on the host, so there is something to connect to your application, you may have to do this too.)


Comments