简体   繁体   English

java.sql.SQLException:打开连接时出错

[英]java.sql.SQLException: Error opening connection

I'm trying to connect to an SQLite using MacBook Apple Silicone M1.我正在尝试使用 MacBook Apple Silicone M1 连接到 SQLite。 Here is my code to make the connection the URL is exactly the SQLite name when I create it inside IntelliJ.这是我建立连接的代码,当我在 IntelliJ 中创建 URL 时,它正是 SQLite 名称。

Here is the code.这是代码。

 private static final String SQLite_URL = "jdbc:sqlite:identifier.sqlite";
        Connection conn = null;
        if (DatastoreToggles.isUnderTest) {
            try {
                Class.forName("org.sqlite.JDBC");
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
            try {
                conn = DriverManager.getConnection(SQLite_URL_TEST);

                System.out.println("Connection to test SQLite successful");

            }
            catch (SQLException e) {
                System.out.println(e.getMessage());
            }
        }
        else {
            try {
                conn = DriverManager.getConnection(SQLite_URL);

                System.out.println("Connection to SQLite successful");

            }
            catch (SQLException e) {
                System.out.println(e.getMessage());
            }
        }

        return conn;
    }

I already checked other people with similar problems, I did update my maven but the problem is still there.我已经检查过其他有类似问题的人,我确实更新了我的 maven 但问题仍然存在。

  <dependency>
            <groupId>org.xerial</groupId>
            <artifactId>sqlite-jdbc</artifactId>
            <version>3.25.2</version>
        </dependency>

Test connection inside IntelliJ passes but cannot connect with my code. IntelliJ 内部的测试连接通过但无法与我的代码连接。

Here is the report for the console这是控制台的报告完整的错误

M1 support is released in 3.32.3.3 of sqlite-jdbc, but you are using 3.25.2.在 sqlite-jdbc 的 3.32.3.3 中发布了 M1 支持,但您使用的是 3.25.2。 So, please update your dependency所以,请更新你的依赖

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM