java - ClassNotFoundException com.mysql.jdbc.Driver -


This question has been asked several times here, after performing some Google searches and making some updates for the above error, I do not understand why I am still getting that error. I have already added my driver - mysql-connector-java-5.1.5-bin to the classpath:

  Java_Home \ jre \ lib \ Java_Home \ jre \ lib \ ext \ Java_Home \ Lib  

and the code I am using to connect to mysql database:

  try {class.forName ("com.mysql. Jdbc driver "); Connection con = DriverManager.getConnection ("jdbc: mysql: // localhost: 3306 / mail", "root", ""); Statement stmt = con.createStatement (); Results reset rs = stmt.executeQuery ("message_body from deadletter"); String db time; While (rsnext ()) {dbtime = rs.getString (1); Println (dbtime); } Con.close (); } Hold (SQLException e) {System.out.println ("Connection Failed! Test Output Console"); E.printStackTrace (); }}  

and the full stacktrace of the above exception is:

  java.lang.ClassNotFoundException: com.mysql.jdbc: java.net Java on driver Security.AccessController at .URLClassLoader $ 1.run (URLClassLoader.java20000) java.lang.ClassLoader.loadClass on java.net.URLClassLoader.findClass (URLClassLoader.java:307) privileged (basic method) ClassLoder. Java: 307) at sun.misc.Launcher $ AppClassLoader.loadClass (Launcher.java:301) at java.lang.ClassLoader.loadClass (ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal (ClassLoader.java:320 ) At mail.lang.Class.forName0 (Basic Method) at mail.lang.Class.forName (Class.java:169) mail.main (mail.java:114)  

Now, what is wrong I am doing here?

The most common reason is that there are some disputes in your class from where your classes are filled. For example, if you have 2 locations and one has a JDBC driver and the other, if your classloader loads from the first place and wants to use some class driver from 1 location - the driver is not there, then duplicate JARs See what your driver is using


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

kernel - How to create a "Block device" in Windows -