Search in sources :

Example 1 with DatabaseServiceImpl

use of com.skelril.skree.service.internal.database.DatabaseServiceImpl in project Skree by Skelril.

the class DatabaseSystem method init.

@NModuleTrigger(trigger = "PRE_INITIALIZATION")
public void init() {
    try {
        Class.forName("org.mariadb.jdbc.Driver").newInstance();
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        e.printStackTrace();
    }
    try {
        DatabaseConfig config = ConfigLoader.loadConfig("database.json", DatabaseConfig.class);
        String database = config.getDatabase();
        String username = config.getUsername();
        String password = config.getPassword();
        setupHandle(database, username, password);
        runMigrations(database, username, password);
    } catch (IOException e) {
        e.printStackTrace();
    }
    service = new DatabaseServiceImpl();
    Sponge.getEventManager().registerListeners(SkreePlugin.inst(), service);
    Sponge.getServiceManager().setProvider(SkreePlugin.inst(), DatabaseService.class, service);
}
Also used : IOException(java.io.IOException) DatabaseServiceImpl(com.skelril.skree.service.internal.database.DatabaseServiceImpl) NModuleTrigger(com.skelril.nitro.module.NModuleTrigger)

Aggregations

NModuleTrigger (com.skelril.nitro.module.NModuleTrigger)1 DatabaseServiceImpl (com.skelril.skree.service.internal.database.DatabaseServiceImpl)1 IOException (java.io.IOException)1