简体   繁体   English

找不到适用于jdbc:mysql // localhost:3306 / test的驱动程序

[英]No suitable driver found for jdbc:mysql//localhost:3306/test

I am trying to write a java program connecting to a MySQL database. 我正在尝试编写一个连接MySQL数据库的Java程序。 But I am getting this error: 但我收到此错误:

No suitable driver found for jdbc:mysql//localhost:3306/test 找不到适用于jdbc:mysql // localhost:3306 / test的驱动程序

I have already installed mysql-connector-java.5.1.23-bin.jar . 我已经安装了mysql-connector-java.5.1.23-bin.jar I am still getting this error. 我仍然收到此错误。

Here is my program: 这是我的程序:

package database_practice;

import java.sql.*;

public class CreateConnection {
        private Connection conn = null;

        public static void main(String args[]) {
            CreateConnection conn = new CreateConnection();
                conn.getConnection();
        }


        public Connection getConnection() {
            try {
                String url = "jdbc:mysql//localhost:3306/test";
                String username = "root";
                String password = "admin1234";

            Class.forName("com.mysql.jdbc.Driver").newInstance();
            conn = DriverManager.getConnection(url, username, password);
            System.out.println("Database Created...!!!");
        }

        catch (Exception e) {
            e.printStackTrace();
            System.out.println("Error occured while connecting to database");
        }
            return conn;
    }
}

Your connection string is wrong. 您的连接字符串错误。 This: 这个:

"jdbc:mysql//localhost:3306/test"

should be: 应该:

"jdbc:mysql://localhost:3306/test"

Note the colon after " mysql ". 注意“ mysql ”后的冒号。

暂无
暂无

声明:本站的技术帖子网页,遵循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:mysql:// localhost:3306 / test的驱动程序 - 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/student 的驱动程序” - Found this error "No suitable driver found for jdbc:mysql//localhost:3306/student" 如何解决:找不到适合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 / 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