diff --git a/dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/datasource/DatabasePoolUtils.java b/dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/datasource/DatabasePoolUtils.java index f1d52227ba0..ecb3cef22f4 100644 --- a/dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/datasource/DatabasePoolUtils.java +++ b/dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/datasource/DatabasePoolUtils.java @@ -158,7 +158,9 @@ public static DataSource createDbPool(DbPoolConfig config) DhisConfigurationProvider dhisConfig = config.getDhisConfig(); final String driverClassName = - dhisConfig.getProperty(mapper.getConfigKey(CONNECTION_DRIVER_CLASS)); + firstNonNull( + config.getDriverClassName(), + dhisConfig.getProperty(mapper.getConfigKey(CONNECTION_DRIVER_CLASS))); final String jdbcUrl = firstNonNull( config.getJdbcUrl(), dhisConfig.getProperty(mapper.getConfigKey(CONNECTION_URL))); @@ -194,6 +196,7 @@ public static void testConnection(DataSource dataSource) { } } + /** Create a data source based on a Hikari connection pool. */ private static DataSource createHikariDbPool( String username, String password, @@ -235,6 +238,7 @@ private static DataSource createHikariDbPool( return ds; } + /** Create a data source based on a C3p0 connection pool. */ private static ComboPooledDataSource createC3p0DbPool( String username, String password, String driverClassName, String jdbcUrl, DbPoolConfig config) throws PropertyVetoException { @@ -308,6 +312,7 @@ private static ComboPooledDataSource createC3p0DbPool( return pooledDataSource; } + /** Creates a data source with no connection pool. */ private static DriverManagerDataSource createNoPoolDataSource( String username, String password, String driverClassName, String jdbcUrl) { final DriverManagerDataSource unPooledDataSource = new DriverManagerDataSource(); diff --git a/dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/datasource/model/DbPoolConfig.java b/dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/datasource/model/DbPoolConfig.java index b14990d6644..d47d4e9420e 100644 --- a/dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/datasource/model/DbPoolConfig.java +++ b/dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/datasource/model/DbPoolConfig.java @@ -45,6 +45,8 @@ public class DbPoolConfig { private DhisConfigurationProvider dhisConfig; + private String driverClassName; + private String jdbcUrl; private String username; diff --git a/dhis-2/dhis-support/dhis-support-sql/pom.xml b/dhis-2/dhis-support/dhis-support-sql/pom.xml index d26ebcf726a..b27f0e772e6 100644 --- a/dhis-2/dhis-support/dhis-support-sql/pom.xml +++ b/dhis-2/dhis-support/dhis-support-sql/pom.xml @@ -21,60 +21,52 @@ org.hisp.dhis - dhis-support-commons + dhis-api - org.hisp.dhis - dhis-support-external + dhis-support-commons - org.hisp.dhis - dhis-api + dhis-support-external - org.springframework spring-context - org.springframework spring-beans - org.springframework spring-jdbc + + javax.annotation javax.annotation-api - org.apache.commons commons-text - org.apache.commons commons-lang3 - org.apache.commons commons-collections4 - org.projectlombok lombok provided - org.slf4j slf4j-api diff --git a/dhis-2/dhis-support/pom.xml b/dhis-2/dhis-support/pom.xml index 5366126ee28..df09fcd878e 100644 --- a/dhis-2/dhis-support/pom.xml +++ b/dhis-2/dhis-support/pom.xml @@ -17,11 +17,11 @@ dhis-support-db-migration dhis-support-test dhis-support-external + dhis-support-sql dhis-support-hibernate dhis-support-audit dhis-support-system dhis-support-jdbc - dhis-support-sql dhis-support-expression-parser dhis-support-artemis dhis-support-cache-invalidation