Search in sources :

Example 1 with PostgreSqlDataSource

use of fr.xephi.authme.datasource.PostgreSqlDataSource in project AuthMeReloaded by AuthMe.

the class DataSourceProvider method createDataSource.

/**
 * Sets up the data source.
 *
 * @return the constructed data source
 * @throws SQLException when initialization of a SQL data source failed
 */
private DataSource createDataSource() throws SQLException {
    DataSourceType dataSourceType = settings.getProperty(DatabaseSettings.BACKEND);
    DataSource dataSource;
    switch(dataSourceType) {
        case MYSQL:
            dataSource = new MySQL(settings, mySqlExtensionsFactory);
            break;
        case POSTGRESQL:
            dataSource = new PostgreSqlDataSource(settings, mySqlExtensionsFactory);
            break;
        case SQLITE:
            dataSource = new SQLite(settings, dataFolder);
            break;
        default:
            throw new UnsupportedOperationException("Unknown data source type '" + dataSourceType + "'");
    }
    if (settings.getProperty(DatabaseSettings.USE_CACHING)) {
        dataSource = new CacheDataSource(dataSource, playerCache);
    }
    if (DataSourceType.SQLITE.equals(dataSourceType)) {
        checkDataSourceSize(dataSource);
    }
    return dataSource;
}
Also used : CacheDataSource(fr.xephi.authme.datasource.CacheDataSource) DataSourceType(fr.xephi.authme.datasource.DataSourceType) MySQL(fr.xephi.authme.datasource.MySQL) SQLite(fr.xephi.authme.datasource.SQLite) PostgreSqlDataSource(fr.xephi.authme.datasource.PostgreSqlDataSource) CacheDataSource(fr.xephi.authme.datasource.CacheDataSource) DataSource(fr.xephi.authme.datasource.DataSource) PostgreSqlDataSource(fr.xephi.authme.datasource.PostgreSqlDataSource)

Aggregations

CacheDataSource (fr.xephi.authme.datasource.CacheDataSource)1 DataSource (fr.xephi.authme.datasource.DataSource)1 DataSourceType (fr.xephi.authme.datasource.DataSourceType)1 MySQL (fr.xephi.authme.datasource.MySQL)1 PostgreSqlDataSource (fr.xephi.authme.datasource.PostgreSqlDataSource)1 SQLite (fr.xephi.authme.datasource.SQLite)1