ClassNotFoundException: com.mysql.jdbc.Driver [дубликат]

На этот вопрос уже есть ответ:

ClassNotFoundException com.mysql.jdbc.Driver [дубликат] 21 ответ Подключить Java к базе данных MySQL 12 ответов

Этот вопрос часто задавался здесь, но я все еще не могу решить свою проблему: я поставилmysql-connector-java-5.1.18-bin вC:\Program Files\Java\jre6\lib\ext папка. У меня есть этот код:

    // 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();
} 

и я получаю ClassNotFoundException со следующей трассировкой стека:

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)

Я тоже изменилсяCLASSPATH переменная будетC:\Program Files\Java\jre6\lib\ext\mysql-connector-java-5.1.18-bin Любые идеи

Ответы на вопрос(6)

Ваш ответ на вопрос