]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3507 H2 driver should be registered before the connection
authorDavid Gageot <david@gageot.net>
Fri, 6 Jul 2012 14:41:41 +0000 (16:41 +0200)
committerDavid Gageot <david@gageot.net>
Fri, 6 Jul 2012 14:42:20 +0000 (16:42 +0200)
This works on java6 but not in java5

sonar-server/src/main/java/org/sonar/server/database/EmbeddedDatabase.java
sonar-server/src/test/java/org/sonar/server/database/EmbeddedDatabaseTest.java

index 9c1a72659832d2c8c4a352940619f8b0c48f0850..1910ef96573e186243e767e882ae0645befd6124 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.server.database;
 
+import org.h2.Driver;
+
 import org.apache.commons.lang.StringUtils;
 import org.h2.tools.Server;
 import org.slf4j.Logger;
@@ -85,6 +87,7 @@ public class EmbeddedDatabase {
   private void createDatabase(File dbHome, String user, String password) throws SQLException {
     String url = String.format("jdbc:h2:%s/sonar;USER=%s;PASSWORD=%s", dbHome.getAbsolutePath(), user, password);
 
+    DriverManager.registerDriver(new Driver());
     DriverManager.getConnection(url).close();
   }
 
index 301bfab68cd8b3f48da6d3a485cfc4dd91c90656..ceace45b1f10fe465b50ad88a7f96dda3ec5a6e8 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.server.database;
 
+import org.h2.Driver;
+
 import org.junit.Test;
 import org.sonar.api.config.Settings;
 import org.sonar.api.database.DatabaseProperties;
@@ -39,6 +41,7 @@ public class EmbeddedDatabaseTest {
 
     try {
       String driverUrl = String.format("jdbc:h2:tcp://localhost:%d/sonar;USER=login;PASSWORD=pwd", port);
+      DriverManager.registerDriver(new Driver());
       DriverManager.getConnection(driverUrl).close();
     } catch (Exception ex) {
       fail("Unable to connect after start");