mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-12-03 15:33:32 +01:00
A little database utility
This commit is contained in:
parent
f38296e4b1
commit
8f95056e31
@ -21,6 +21,7 @@ import java.util.function.Consumer;
|
|||||||
public class DataManagerAbstract {
|
public class DataManagerAbstract {
|
||||||
protected final DatabaseConnector databaseConnector;
|
protected final DatabaseConnector databaseConnector;
|
||||||
protected final Plugin plugin;
|
protected final Plugin plugin;
|
||||||
|
protected final DatabaseType type;
|
||||||
|
|
||||||
protected final ExecutorService asyncPool = Executors.newSingleThreadExecutor();
|
protected final ExecutorService asyncPool = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
@ -30,6 +31,7 @@ public class DataManagerAbstract {
|
|||||||
public DataManagerAbstract(DatabaseConnector databaseConnector, Plugin plugin) {
|
public DataManagerAbstract(DatabaseConnector databaseConnector, Plugin plugin) {
|
||||||
this.databaseConnector = databaseConnector;
|
this.databaseConnector = databaseConnector;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.type = databaseConnector.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -196,4 +198,11 @@ public class DataManagerAbstract {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSyntax(String string, DatabaseType type) {
|
||||||
|
if (this.type == type) {
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,4 +31,6 @@ public interface DatabaseConnector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Connection getConnection();
|
Connection getConnection();
|
||||||
|
|
||||||
|
DatabaseType getType();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.songoda.core.database;
|
||||||
|
|
||||||
|
public enum DatabaseType {
|
||||||
|
|
||||||
|
MARIADB,
|
||||||
|
MYSQL,
|
||||||
|
SQLITE
|
||||||
|
}
|
@ -62,4 +62,9 @@ public class MariaDBConnector implements DatabaseConnector {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DatabaseType getType() {
|
||||||
|
return DatabaseType.MARIADB;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,4 +61,9 @@ public class MySQLConnector implements DatabaseConnector {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DatabaseType getType() {
|
||||||
|
return DatabaseType.MYSQL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,4 +65,9 @@ public class SQLiteConnector implements DatabaseConnector {
|
|||||||
}
|
}
|
||||||
return this.connection;
|
return this.connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DatabaseType getType() {
|
||||||
|
return DatabaseType.SQLITE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user