简体   繁体   English

Eclipse:我已经添加了JAR文件。 java.lang.ClassNotFoundException:com.mysql.jdbc.Driver

[英]Eclipse: I have added the JAR file. java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

I am using Eclipse, I have added the JAR file under lib->mysql-connector...jar , but I am still getting the error that the class is not found. 我正在使用Eclipse,已在lib->mysql-connector...jar下添加了JAR文件,但仍收到未找到该类的错误。

I have read many other posts related to the same problem, and they point to adding the JAR file, but I have already done this step. 我已经阅读了许多与同一问题相关的其他文章,它们指向添加JAR文件,但是我已经完成了这一步。

Thanks for the help. 谢谢您的帮助。

Error: 错误:

Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jbc.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:171)
    at TTDB.TT_DoQuery(TTDB.java:65)
    at TTDB.TT_Insert(TTDB.java:58)
    at TTDB.main(TTDB.java:109)

Code: 码:

    try{
        Class.forName("com.mysql.jbc.Driver");
        // Connect to the database
        connect = DriverManager.getConnection(address);

        statement = connect.createStatement();
        resultSet = statement.executeQuery(query);

    }
    catch (Exception e){
        throw e;
    } finally {
        TT_Close();
    }

**Screenshots* **截图*

在此处输入图片说明

在此处输入图片说明

You're missing a d . 您缺少d

Class.forName("com.mysql.jdbc.Driver");

Note that JDBC 4 compliant Driver implementations don't need to be explicitly loaded with Class.forName(String) . 请注意,不需要使用Class.forName(String)显式加载兼容JDBC 4的Driver实现。 The Driver is registered through classpath scanning. 通过类路径扫描注册Driver Find out if your library is JDBC 4 compliant and remove the call to Class.forName(String) if it is. 找出您的库是否兼容JDBC 4,并删除对Class.forName(String)的调用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.ClassNotFoundException: com.mysql.jdbc.Driver in Eclipse - java.lang.ClassNotFoundException: com.mysql.jdbc.Driver in Eclipse 线程“主”中的异常 java.lang.ClassNotFoundException: com.mysql.Z84BEFFD3A00D496736 中已添加引用库 jar 文件,错误仍然存在 - Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver in vscode. have added referenced libraries jar file, error persists java.lang.ClassNotFoundException: com.mysql.jdbc.driver 错误,jar 文件已经导入 - java.lang.ClassNotFoundException: com.mysql.jdbc.driver error with jar file already imported java.lang.ClassNotFoundException:Eclipse中的com.mysql.jdbc.Driver,即使已引用mysql-connector jar - java.lang.ClassNotFoundException: com.mysql.jdbc.Driver in Eclipse even though the mysql-connector jar is referenced java.lang.ClassNotFoundException:com.mysql.jdbc.Driver - java.lang.ClassNotFoundException: com.mysql.jdbc.Driver 错误:java.lang.ClassNotFoundException:com.mysql.jdbc.Driver? - error: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver? Ubuntu中的java.lang.classnotfoundexception com.mysql.jdbc.driver - java.lang.classnotfoundexception com.mysql.jdbc.driver in ubuntu Maven java.lang.ClassNotFoundException:com.mysql.jdbc.Driver - Maven java.lang.ClassNotFoundException: com.mysql.jdbc.Driver Maven - java.lang.ClassNotFoundException: com.mysql.jdbc.Driver - Maven - java.lang.ClassNotFoundException: com.mysql.jdbc.Driver Java.lang.ClassnotfoundException com.mysql.jdbc.Driver - Java.lang.ClassnotfoundException com.mysql.jdbc.Driver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM