mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-09 20:21:07 +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();
|
dataSource = getDataSource();
|
||||||
|
|
||||||
|
if (dataSource == null) {
|
||||||
|
callback.onError(new SQLException("Failed to get data source"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try (Connection con = dataSource.getConnection()) {
|
try (Connection con = dataSource.getConnection()) {
|
||||||
// Update database structure if necessary
|
// Update database structure if necessary
|
||||||
update();
|
update();
|
||||||
|
@ -20,6 +20,16 @@ public class SQLite extends Database {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
HikariDataSource getDataSource() {
|
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 folder = plugin.getDataFolder();
|
||||||
File dbFile = new File(folder, "shops.db");
|
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.getLogger().severe("Failed to create database file");
|
||||||
plugin.debug("Failed to create database file");
|
plugin.debug("Failed to create database file");
|
||||||
plugin.debug(ex);
|
plugin.debug(ex);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user