use of com.evolveum.midpoint.repo.api.RepositoryServiceFactoryException in project midpoint by Evolveum.
the class DataSourceFactory method createDataSource.
public DataSource createDataSource(String applicationName) throws RepositoryServiceFactoryException {
LOGGER.info("Loading datasource.");
if (configuration == null) {
throw new RepositoryServiceFactoryException("SQL configuration is null, couldn't create datasource.");
}
if (StringUtils.isNotEmpty(configuration.getDataSource())) {
try {
LOGGER.info("JNDI datasource present in configuration, looking for '{}'.", configuration.getDataSource());
dataSource = createJndiDataSource();
} catch (Exception ex) {
throw new RepositoryServiceFactoryException("Couldn't initialize datasource using datasource " + configuration.getDataSource() + ", reason: " + ex.getMessage(), ex);
}
} else {
String jdbcUrl = configuration.getJdbcUrl(applicationName);
try {
LOGGER.info("Constructing default datasource with connection pooling; JDBC URL: {}" + "\n Using driver: {}", jdbcUrl, configuration.getDriverClassName());
HikariConfig config = createHikariConfig(applicationName);
dataSource = new HikariDataSource(config);
internalDataSource = true;
} catch (Exception ex) {
throw new RepositoryServiceFactoryException("Couldn't initialize datasource using JDBC URL " + jdbcUrl + ", reason: " + ex.getMessage(), ex);
}
}
return dataSource;
}
Aggregations