Skip to content

Commit

Permalink
更新 SQLite.java
Browse files Browse the repository at this point in the history
  • Loading branch information
shulng authored Jun 11, 2024
1 parent 4b40a33 commit a24b668
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/main/java/cc/baka9/catseedlogin/bukkit/database/SQLite.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public SQLite(JavaPlugin plugin) {
super(plugin);
}

public Connection getConnection() {
public Connection getConnection() throws ClassNotFoundException, SQLException {
if (this.connection != null && !this.connection.isClosed()) {
return this.connection;
}
Expand All @@ -22,14 +22,10 @@ public Connection getConnection() {
plugin.getDataFolder().mkdir();
}

try {
// 加载SQLite的JDBC驱动
Class.forName("org.sqlite.JDBC");
// 创建数据库连接
this.connection = DriverManager.getConnection("jdbc:sqlite:" + plugin.getDataFolder().getAbsolutePath() + "/accounts.db");
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
// 加载SQLite的JDBC驱动
Class.forName("org.sqlite.JDBC");
// 创建数据库连接
this.connection = DriverManager.getConnection("jdbc:sqlite:" + plugin.getDataFolder().getAbsolutePath() + "/accounts.db");

return this.connection;
}
Expand Down

0 comments on commit a24b668

Please sign in to comment.