java - 无法从 Eclipse DataSource Explorer 连接到 MySQl 数据库

标签 java eclipse jakarta-ee jdbc

http://motionsharing.com/site/download/acefad55f1e81e456d71a7448b278915

无法从 Eclipse DataSource Explorer 连接到 MySQl 数据库。

我调整了合适的驱动程序,但我无法连接。 P.S.:我可以连接到 derby 数据库,也可以连接到 mysql 数据库,但只能通过代码连接,但我想从 Data Source Explorer 连接到 mysql 数据库以获得创建表等的可能性。

怎么了?

我可以通过代码连接。

public static void main(String args[]) {
    try {
        Class.forName("com.mysql.jdbc.Driver");
        System.out.println("Driver loading success!");
        String url = "jdbc:mysql://localhost:3306/mydb";
        String name = "root";
        String password = "root";
        try {
            Connection con = DriverManager.getConnection(url, name, password);
            System.out.println("Connected.");
            con.close();
            System.out.println("Disconnected.");
        } catch (SQLException e) {
            e.printStackTrace();
        }

    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
}

最佳答案

您需要download MySQL JDBC 驱动程序并将其添加到设置中。

当您尝试在数据源资源管理器中创建新的连接配置文件时,您将看到这些屏幕。在最后一步中,您必须指向正确下载的 JAR 文件。

enter image description here enter image description here enter image description here enter image description here

关于java - 无法从 Eclipse DataSource Explorer 连接到 MySQl 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9421234/

相关文章:

java - 如何为 Eclipse 中构建的 Maven 聚合器项目定义 JRE?

eclipse - 如何管理不断增长的 Eclipse 配置?

java - 已更改为 1.6

JAVA ClassLoad 相同的类名

java - 连接到接受套接字连接的 Java EE 应用程序

java - Mysql表不存在/JPA注解

java - Json MongoDb 查询中的 Spring-boot 可选 ArrayList 参数

java - 抽象类可以有final方法吗?

Android 应用程序无法在模拟器上运行

java - Eclipse 如何打印缺失的库