Search in sources :

Example 1 with MigratorConfiguration

use of com.alessiodp.core.common.storage.sql.migrator.MigratorConfiguration in project ADP-Core by AlessioDP.

the class SQLDispatcher method init.

@Override
public void init() {
    // Initialize DAO
    connectionFactory = initConnectionFactory();
    // Check if initialized
    if (connectionFactory != null) {
        connectionFactory.init();
        // Check for failures
        if (!connectionFactory.isFailed()) {
            // Setup logger
            connectionFactory.getJdbi().setSqlLogger(new SqlLogger() {

                @Override
                public void logBeforeExecution(StatementContext context) {
                    plugin.getLoggerManager().logDebug(String.format(Constants.DEBUG_DB_QUERY_EXECUTE, context.getRenderedSql()), true);
                }
            });
            try {
                MigratorConfiguration migratorConfiguration = prepareMigrator();
                migrateTables(migratorConfiguration.load(plugin, this));
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }
    }
}
Also used : SqlLogger(org.jdbi.v3.core.statement.SqlLogger) MigratorConfiguration(com.alessiodp.core.common.storage.sql.migrator.MigratorConfiguration) StatementContext(org.jdbi.v3.core.statement.StatementContext)

Aggregations

MigratorConfiguration (com.alessiodp.core.common.storage.sql.migrator.MigratorConfiguration)1 SqlLogger (org.jdbi.v3.core.statement.SqlLogger)1 StatementContext (org.jdbi.v3.core.statement.StatementContext)1