aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-07-11 18:10:04 +0200
committerDavid Gageot <david@gageot.net>2012-07-11 18:11:39 +0200
commite9143e13398638eca1be4fa79d8176b94348b4d3 (patch)
treefcc10949a9f660df206704aa42c08694b4b6392d /sonar-core
parentde901ced10098dd12db964d5a280e2cb5421a9bf (diff)
downloadsonarqube-e9143e13398638eca1be4fa79d8176b94348b4d3.tar.gz
sonarqube-e9143e13398638eca1be4fa79d8176b94348b4d3.zip
SONAR-2965 FIX enforce validation query on DataSource
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/dialect/Dialect.java2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/persistence/H2Database.java20
2 files changed, 14 insertions, 8 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/Dialect.java b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/Dialect.java
index 35a26c4b42b..bb699f82b7b 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/Dialect.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/Dialect.java
@@ -71,7 +71,7 @@ public interface Dialect {
/**
* Query used to validate the jdbc connection.
- *
+ *
* @since 3.2
*/
String getValidationQuery();
diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/H2Database.java b/sonar-core/src/test/java/org/sonar/core/persistence/H2Database.java
index 3767121de0d..55db7c2ed94 100644
--- a/sonar-core/src/test/java/org/sonar/core/persistence/H2Database.java
+++ b/sonar-core/src/test/java/org/sonar/core/persistence/H2Database.java
@@ -20,6 +20,7 @@
package org.sonar.core.persistence;
import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.commons.dbcp.BasicDataSourceFactory;
import org.hibernate.cfg.Environment;
import org.sonar.core.persistence.dialect.Dialect;
import org.sonar.core.persistence.dialect.H2;
@@ -52,13 +53,18 @@ public class H2Database implements Database {
*/
private void startDatabase() {
try {
- datasource = new BasicDataSource();
- datasource.setDriverClassName("org.h2.Driver");
- datasource.setUsername("sonar");
- datasource.setPassword("sonar");
- datasource.setUrl("jdbc:h2:mem:sonar2");
- datasource.setMaxActive(2);
- datasource.setMaxIdle(2);
+ Properties properties = new Properties();
+ properties.put("driverClassName", "org.h2.Driver");
+ properties.put("username", "sonar");
+ properties.put("password", "sonar");
+ // properties.put("url", "jdbc:h2:mem:sonar2;TRACE_LEVEL_SYSTEM_OUT=2");
+ properties.put("url", "jdbc:h2:mem:sonar2");
+
+ // limit to 2 because of Hibernate and MyBatis
+ properties.put("maxActive", "2");
+ properties.put("maxIdle", "2");
+ datasource = (BasicDataSource) BasicDataSourceFactory.createDataSource(properties);
+
} catch (Exception e) {
throw new IllegalStateException("Fail to start H2", e);
}