简体   繁体   English

发现此错误“没有找到适合 jdbc:mysql//localhost:3306/student 的驱动程序”

[英]Found this error "No suitable driver found for jdbc:mysql//localhost:3306/student"

I was try to create simple java student GUI app in IntelliJ IDEA and its working fine.我试图在IntelliJ IDEA中创建简单的 java 学生GUI应用程序,并且工作正常。 Then I just try to connect database to inset all data into MYSQL, so I create Schema( student ) and Table( appointment ) in MySQL Workbatch and then connect that database in IntelliJ IDEA Database window you can see in the picture and its successfully configured it.然后我只是尝试连接数据库以将所有数据插入 MYSQL,所以我在MySQL Workbatch中创建模式( student )和表( appointment ),然后在IntelliJ IDEA Database Z05B8C74CBD96FBF2DE4C1A3527 中连接该数据库,您可以在图片中看到它成功配置的 FBF2DE4C1A3527 .

Now I try to create connection via below line.现在我尝试通过下面的行创建连接。

Connection con = DriverManager.getConnection("jdbc:mysql//localhost:3306/student","root","root"); Connection con = DriverManager.getConnection("jdbc:mysql//localhost:3306/student","root","root");

But this line give me this error Error: No suitable driver found for jdbc:mysql//localhost:3306/student但是这一行给了我这个错误Error: No suitable driver found for jdbc:mysql//localhost:3306/student

So I google it and I found this line.所以我谷歌它,我找到了这条线。

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

but this line give this error Error: com.mysql.cj.jdbc.Driver但是这条线给出了这个错误Error: com.mysql.cj.jdbc.Driver

Please everyone have a look in it, Its very helpful to me and other one who face this issue.请大家看看它,它对我和其他面临这个问题的人非常有帮助。

在此处输入图像描述

 private DBconnectionSingleton() throws SQLException {
    // create single instance of DB connection 
    Properties connectionProps = new Properties();
    connectionProps.put("user", login);
    connectionProps.put("password", password);// port & db name
    System.out.println("Loading driver...");


    try {
        Class.forName("com.mysql.cj.jdbc.Driver");
        System.out.println("Driver loaded!");
    } catch (ClassNotFoundException e) {
        throw new IllegalStateException("Cannot find the driver in the classpath!", e);
    }

    conn = DriverManager.getConnection(
            "jdbc:mysql://localhost:3306/student",
            connectionProps
    );
}

暂无
暂无

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

相关问题 错误:找不到适用于jdbc:mysql:// localhost:3306 / test的驱动程序 - ERROR: No suitable driver found for jdbc:mysql://localhost:3306/test JDBC JAVA找不到适合的驱动程序jdbc:mysql:// localhost:3306 / voting - JDBC JAVA No suitable driver found for jdbc:mysql://localhost:3306/voting 如何解决:找不到适合jdbc的驱动:mysql://localhost:3306/sampledb - How to solve: No suitable driver found for jdbc:mysql://localhost:3306/sampledb 找不到适用于jdbc:mysql:// localhost:3306 / jpa的驱动程序 - No suitable driver found for jdbc:mysql://localhost:3306/ jpa 找不到适用于jdbc:mysql // localhost:3306 / test的驱动程序 - No suitable driver found for jdbc:mysql//localhost:3306/test 找不到适用于jdbc:mysql:// localhost:3306 / test的驱动程序 - No suitable driver found for jdbc:mysql://localhost:3306/test 找不到适用于jdbc:mysql / localhost:3306 / world的驱动程序 - No suitable driver found for jdbc:mysql/localhost:3306/world Eclipse - Hibernate:没有为jdbc找到合适的驱动程序:mysql:// localhost:3306 / hibernatedb - Eclipse - Hibernate : No suitable driver found for jdbc:mysql://localhost:3306/hibernatedb 找不到适用于jdbc:mysql // localhost:3306 / demo的驱动程序吗?useSSL = false - No suitable driver found for jdbc:mysql//localhost:3306/demo?useSSL=false SQLException:找不到适用于jdbc:mysql:// localhost:3306 / dbname的驱动程序 - SQLException: No suitable driver found for jdbc:mysql://localhost:3306/dbname
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM