简体   繁体   English

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

I know this has been asked before, but in my case, adding the library (Rightclickling project>Buildpath>Configure buildpath>Add External JARs> Select JAR) hasn't worked and I still keep receiving the error. 我知道以前曾有人问过这个问题,但就我而言,添加库(Rightclickling项目> Buildpath>配置构建路径>添加外部JAR>选择JAR)一直没有奏效,但我仍然继续收到该错误。

Here's my code: 这是我的代码:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class Client {
    public static void main(String[] args) throws Exception
    {
            getConnection();
    }

    public static Connection getConnection() throws Exception
    {
        try
        {
            String driver = "com.mysql.jbdc.Driver";
            String url = "jdbc:mysql://localhost:3306/testdb";
            String username = "root";
            String password = "admin";

            Class.forName(driver);

            //Creating a variable for the connection called "con"
            Connection con = DriverManager.getConnection(url, username, password);

            System.out.println("Connected");
            return con;

        } catch(Exception e){System.out.println(e);}

        return null;
    }
}

And "mysql-connector-java-52.40-bin.jar" appears under "Referenced Libraries". 并且“ mysql-connector-java-52.40-bin.jar”出现在“参考库”下。

Any help would be appreciated. 任何帮助,将不胜感激。

Nevermind, I'm an idiot. 没关系,我是个白痴。 It has to be "jdbc" instead of "jbdc". 它必须是“ jdbc”而不是“ jbdc”。 Carry on. 继续。

暂无
暂无

声明:本站的技术帖子网页,遵循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.jdbc.Driver 即使 jar 文件放在类路径中 - java.lang.ClassNotFoundException: com.mysql.jdbc.Driver even when jar files are placed at classpath Eclipse:我已经添加了JAR文件。 java.lang.ClassNotFoundException:com.mysql.jdbc.Driver - Eclipse: I have added the JAR file. java.lang.ClassNotFoundException: com.mysql.jdbc.Driver java.lang.ClassNotFoundException: com.mysql.jdbc.Driver 抛出异常,即使依赖项被添加到 pom.xml 并且驱动程序已注册 - java.lang.ClassNotFoundException: com.mysql.jdbc.Driver exception thrown, even though dependency was added to pom.xml and the driver is registered 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