Note that there are some explanatory texts on larger screens.

plurals
  1. POClassNotFoundException: com.mysql.jdbc.Driver
    primarykey
    data
    text
    <p>This question has been asked a lot here, but i still can't fix my problem: I put <code>mysql-connector-java-5.1.18-bin</code> into <code>C:\Program Files\Java\jre6\lib\ext</code> folder. I have this code:</p> <pre><code> // Load the database driver Class.forName("com.mysql.jdbc.Driver"); // Get a connection to the database Connection conn = DriverManager.getConnection( "jdbc:mysql://localhost:3306/mysql", "root", "4958ps"); // Get a statement from the connection Statement stmt = conn.createStatement() ; // Execute the query ResultSet rs = stmt.executeQuery( "SELECT * FROM Cust" ) ; // Loop through the result set while( rs.next() ) System.out.println( rs.getString(1) ) ; // Close the result set, statement and the connection rs.close() ; stmt.close() ; conn.close() ; } catch( SQLException se ) { System.out.println( "SQL Exception:" ) ; // Loop through the SQL Exceptions while( se != null ) { System.out.println( "State : " + se.getSQLState() ) ; System.out.println( "Message: " + se.getMessage() ) ; System.out.println( "Error : " + se.getErrorCode() ) ; se = se.getNextException() ; } } catch( Exception e ) { e.printStackTrace(); } </code></pre> <p>and i get a ClassNotFoundException with the following stack trace:</p> <pre><code>java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at pack.Test.main(Test.java:14) </code></pre> <p>I also changed <code>CLASSPATH</code> variable to be <code>C:\Program Files\Java\jre6\lib\ext\mysql-connector-java-5.1.18-bin</code> Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload