【发布时间】:2021-12-31 01:04:41
【问题描述】:
我正在尝试使用 MacBook Apple Silicone M1 连接到 SQLite。 这是我在 IntelliJ 中创建 URL 时建立连接的代码,它正是 SQLite 名称。
这里是代码。
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;
}
我已经检查过其他有类似问题的人,我确实更新了我的 maven,但问题仍然存在。
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.25.2</version>
</dependency>
IntelliJ 内部的测试连接通过但无法连接到我的代码。
【问题讨论】:
标签: java spring-boot sqlite