aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-07-15 21:54:49 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2012-07-15 21:54:49 +0200
commit9f6f69e368d06a0ae064ad9fd6fded06307d0c99 (patch)
treea2093084eea754abce330c7c706c229d8d85af13 /sonar-core
parent3304cf145f064766b10f9e657d8b82f3e6f25465 (diff)
downloadsonarqube-9f6f69e368d06a0ae064ad9fd6fded06307d0c99.tar.gz
sonarqube-9f6f69e368d06a0ae064ad9fd6fded06307d0c99.zip
Fix some quality flaws
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/DefaultDatabase.java14
1 files changed, 5 insertions, 9 deletions
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");