use of com.djrapitops.plan.storage.database.SQLDB in project Plan by plan-player-analytics.
the class DBPreparer method prepareDBByName.
private SQLDB prepareDBByName(String dbName) {
PlanConfig config = dependencies.config();
config.set(WebserverSettings.PORT, testPortNumber);
config.set(DatabaseSettings.TYPE, dbName);
dependencies.enable();
DBSystem dbSystem = dependencies.dbSystem();
SQLDB db = (SQLDB) dbSystem.getActiveDatabaseByName(dbName);
db.setTransactionExecutorServiceProvider(MoreExecutors::newDirectExecutorService);
db.init();
return db;
}
use of com.djrapitops.plan.storage.database.SQLDB in project Plan by plan-player-analytics.
the class DBPreparer method prepareMySQL.
public Optional<Database> prepareMySQL() {
PlanConfig config = dependencies.config();
Optional<String> formattedDB = setUpMySQLSettings(config);
if (formattedDB.isPresent()) {
String formattedDatabase = formattedDB.get();
SQLDB mysql = prepareDBByName(DBType.MYSQL.getName());
mysql.executeTransaction(new Transaction() {
@Override
protected void performOperations() {
execute("DROP DATABASE " + formattedDatabase);
execute("CREATE DATABASE " + formattedDatabase);
execute("USE " + formattedDatabase);
}
});
return Optional.of(mysql);
}
return Optional.empty();
}
Aggregations