mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-08 11:41:10 +00:00
Initialize SQLite driver before use
This commit is contained in:
parent
341c17b047
commit
1b1e5de47e
@ -228,6 +228,11 @@ public abstract class Database {
|
||||
|
||||
dataSource = getDataSource();
|
||||
|
||||
if (dataSource == null) {
|
||||
callback.onError(new SQLException("Failed to get data source"));
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = dataSource.getConnection()) {
|
||||
// Update database structure if necessary
|
||||
update();
|
||||
|
@ -20,6 +20,16 @@ public class SQLite extends Database {
|
||||
|
||||
@Override
|
||||
HikariDataSource getDataSource() {
|
||||
try {
|
||||
// Initialize driver class so HikariCP can find it
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
} catch (ClassNotFoundException e) {
|
||||
plugin.getLogger().severe("Failed to initialize SQLite driver");
|
||||
plugin.debug("Failed to initialize SQLite driver");
|
||||
plugin.debug(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
File folder = plugin.getDataFolder();
|
||||
File dbFile = new File(folder, "shops.db");
|
||||
|
||||
@ -30,6 +40,7 @@ public class SQLite extends Database {
|
||||
plugin.getLogger().severe("Failed to create database file");
|
||||
plugin.debug("Failed to create database file");
|
||||
plugin.debug(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user