From 9f6f69e368d06a0ae064ad9fd6fded06307d0c99 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Sun, 15 Jul 2012 21:54:49 +0200 Subject: Fix some quality flaws --- .../java/org/sonar/core/persistence/DefaultDatabase.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'sonar-core') diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DefaultDatabase.java b/sonar-core/src/main/java/org/sonar/core/persistence/DefaultDatabase.java index 5ee2111cd6d..ae05c0b10d3 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DefaultDatabase.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DefaultDatabase.java @@ -20,7 +20,6 @@ package org.sonar.core.persistence; import com.google.common.annotations.VisibleForTesting; - import org.apache.commons.dbcp.BasicDataSource; import org.apache.commons.dbcp.BasicDataSourceFactory; import org.apache.commons.lang.StringUtils; @@ -29,15 +28,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.config.Settings; import org.sonar.api.database.DatabaseProperties; -import org.sonar.core.persistence.dialect.Dialect; -import org.sonar.core.persistence.dialect.DialectUtils; -import org.sonar.core.persistence.dialect.H2; -import org.sonar.core.persistence.dialect.Oracle; -import org.sonar.core.persistence.dialect.PostgreSql; +import org.sonar.core.persistence.dialect.*; import org.sonar.jpa.session.CustomHibernateConnectionProvider; import javax.sql.DataSource; - import java.sql.SQLException; import java.util.Arrays; import java.util.List; @@ -51,6 +45,8 @@ public class DefaultDatabase implements Database { private static final Logger LOG = LoggerFactory.getLogger(Database.class); + private static final String DEFAULT_URL = "jdbc:h2:tcp://localhost/sonar"; + private Settings settings; private BasicDataSource datasource; private Dialect dialect; @@ -117,7 +113,7 @@ public class DefaultDatabase implements Database { private void initDatasource() throws Exception {// NOSONAR this exception is thrown by BasicDataSourceFactory // but it's correctly caught by start() - LOG.info("Create JDBC datasource to url " + properties.getProperty(DatabaseProperties.PROP_URL, DatabaseProperties.PROP_URL_DEFAULT_VALUE)); + LOG.info("Create JDBC datasource to url " + properties.getProperty(DatabaseProperties.PROP_URL, DEFAULT_URL)); datasource = (BasicDataSource) BasicDataSourceFactory.createDataSource(extractCommonsDbcpProperties(properties)); String initStatement = dialect.getConnectionInitStatement(getSchema()); @@ -212,7 +208,7 @@ public class DefaultDatabase implements Database { private static void completeDefaultProperties(Properties props) { completeDefaultProperty(props, DatabaseProperties.PROP_DRIVER, props.getProperty(DatabaseProperties.PROP_DRIVER_DEPRECATED)); - completeDefaultProperty(props, DatabaseProperties.PROP_URL, DatabaseProperties.PROP_URL_DEFAULT_VALUE); + completeDefaultProperty(props, DatabaseProperties.PROP_URL, DEFAULT_URL); completeDefaultProperty(props, DatabaseProperties.PROP_USER, props.getProperty(DatabaseProperties.PROP_USER_DEPRECATED, DatabaseProperties.PROP_USER_DEFAULT_VALUE)); completeDefaultProperty(props, DatabaseProperties.PROP_PASSWORD, DatabaseProperties.PROP_PASSWORD_DEFAULT_VALUE); completeDefaultProperty(props, DatabaseProperties.PROP_HIBERNATE_HBM2DLL, "validate"); -- cgit v1.2.3