Skip to content

Commit

Permalink
Fix SQLite errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Refrac committed Dec 23, 2023
1 parent dd95bb2 commit d174683
Showing 1 changed file with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package me.refracdevelopment.simpletags.manager.data;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import me.refracdevelopment.simpletags.utilities.Tasks;
import me.refracdevelopment.simpletags.utilities.chat.Color;
import org.sqlite.SQLiteDataSource;

import java.sql.Connection;
import java.sql.PreparedStatement;
Expand All @@ -12,7 +11,7 @@

public class SQLiteManager {

private HikariDataSource dataSource;
private SQLiteDataSource dataSource;

public void createT() {
Tasks.runAsync(this::createTables);
Expand All @@ -21,15 +20,9 @@ public void createT() {
public boolean connect(String path) {
try {
Color.log("&aConnecting to SQLite...");
HikariConfig config = new HikariConfig();
Class.forName("org.sqlite.JDBC");
config.setDriverClassName("org.sqlite.JDBC");
config.setJdbcUrl("jdbc:sqlite:" + path);
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");

dataSource = new HikariDataSource(config);
dataSource = new SQLiteDataSource();
dataSource.setUrl("jdbc:sqlite:" + path);
Color.log("&aConnected to SQLite!");
return true;
} catch (Exception exception) {
Expand Down Expand Up @@ -57,7 +50,11 @@ public boolean isInitiated() {
}

public void close() {
this.dataSource.close();
try {
getConnection().close();
} catch (SQLException e) {
e.printStackTrace();
}
}


Expand Down Expand Up @@ -138,10 +135,10 @@ public void updatePlayerName(UUID uuid, String name) {
}

public void delete() {
execute("DELETE * FROM SimpleTags");
execute("DELETE FROM SimpleTags");
}

public void deletePlayer(UUID uuid) {
execute("DELETE * FROM SimpleTags WHERE uuid=?", uuid.toString());
execute("DELETE FROM SimpleTags WHERE uuid=?", uuid.toString());
}
}

0 comments on commit d174683

Please sign in to comment.