aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-07-17 20:29:12 +0200
committerDavid Gageot <david@gageot.net>2012-07-17 20:29:12 +0200
commit92ca031d4565f24f1fc7c6a4b4e7bcef0f5f4fe8 (patch)
tree38222752087986f8ba6656bd8e648757d3c7b643
parenteea23a747c664c691547be6ad9691218cb5647e4 (diff)
downloadsonarqube-92ca031d4565f24f1fc7c6a4b4e7bcef0f5f4fe8.tar.gz
sonarqube-92ca031d4565f24f1fc7c6a4b4e7bcef0f5f4fe8.zip
Remove more duplication
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/dialect/AbstractDialect.java27
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/dialect/H2.java18
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/dialect/MsSql.java18
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/dialect/MySql.java18
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/dialect/Oracle.java18
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/dialect/PostgreSql.java18
6 files changed, 31 insertions, 86 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/AbstractDialect.java b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/AbstractDialect.java
index 6c0eec35fd1..dbf34ea54ad 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/AbstractDialect.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/AbstractDialect.java
@@ -26,11 +26,20 @@ abstract class AbstractDialect implements Dialect {
private final String id;
private final String activeRecordDialectCode;
private final String activeRecordJdbcAdapter;
+ private final String defaultDriverClassName;
+ private final String trueSqlValue;
+ private final String falseSqlValue;
+ private final String validationQuery;
- protected AbstractDialect(String id, String activeRecordDialectCode, String activeRecordJdbcAdapter) {
+ protected AbstractDialect(String id, String activeRecordDialectCode, String activeRecordJdbcAdapter, String defaultDriverClassName, String trueSqlValue, String falseSqlValue,
+ String validationQuery) {
this.id = id;
this.activeRecordDialectCode = activeRecordDialectCode;
this.activeRecordJdbcAdapter = activeRecordJdbcAdapter;
+ this.defaultDriverClassName = defaultDriverClassName;
+ this.trueSqlValue = trueSqlValue;
+ this.falseSqlValue = falseSqlValue;
+ this.validationQuery = validationQuery;
}
public String getId() {
@@ -44,4 +53,20 @@ abstract class AbstractDialect implements Dialect {
public String getActiveRecordJdbcAdapter() {
return activeRecordJdbcAdapter;
}
+
+ public String getDefaultDriverClassName() {
+ return defaultDriverClassName;
+ }
+
+ public final String getTrueSqlValue() {
+ return trueSqlValue;
+ }
+
+ public final String getFalseSqlValue() {
+ return falseSqlValue;
+ }
+
+ public final String getValidationQuery() {
+ return validationQuery;
+ }
}
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/H2.java b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/H2.java
index 0872be0776b..1bbfbe13bd4 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/H2.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/H2.java
@@ -30,7 +30,7 @@ public class H2 extends AbstractDialect {
public static final String ID = "h2";
public H2() {
- super(ID, "h2", "jdbc");
+ super(ID, "h2", "jdbc", "org.h2.Driver", "true", "false", "SELECT 1");
}
public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
@@ -41,23 +41,7 @@ public class H2 extends AbstractDialect {
return StringUtils.startsWithIgnoreCase(jdbcConnectionURL, "jdbc:h2:");
}
- public String getDefaultDriverClassName() {
- return "org.h2.Driver";
- }
-
public String getConnectionInitStatement(String schema) {
return null;
}
-
- public String getTrueSqlValue() {
- return "true";
- }
-
- public String getFalseSqlValue() {
- return "false";
- }
-
- public String getValidationQuery() {
- return "SELECT 1";
- }
}
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MsSql.java b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MsSql.java
index 7213d59304b..2e35bc3b894 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MsSql.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MsSql.java
@@ -30,7 +30,7 @@ public class MsSql extends AbstractDialect {
public static final String ID = "mssql";
public MsSql() {
- super(ID, "sqlserver", "jdbc");
+ super(ID, "sqlserver", "jdbc", "net.sourceforge.jtds.jdbc.Driver", "1", "0", "SELECT 1");
}
public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
@@ -62,24 +62,8 @@ public class MsSql extends AbstractDialect {
}
}
- public String getDefaultDriverClassName() {
- return "net.sourceforge.jtds.jdbc.Driver";
- }
-
public String getConnectionInitStatement(String schema) {
return null;
}
-
- public String getTrueSqlValue() {
- return "1";
- }
-
- public String getFalseSqlValue() {
- return "0";
- }
-
- public String getValidationQuery() {
- return "SELECT 1";
- }
}
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MySql.java b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MySql.java
index f3e20eacc66..16f3b9117ba 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MySql.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MySql.java
@@ -33,7 +33,7 @@ public class MySql extends AbstractDialect {
public static final String ID = "mysql";
public MySql() {
- super(ID, "mysql", "jdbc");
+ super(ID, "mysql", "jdbc", "com.mysql.jdbc.Driver", "true", "false", "SELECT 1");
}
public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
@@ -54,23 +54,7 @@ public class MySql extends AbstractDialect {
}
}
- public String getDefaultDriverClassName() {
- return "com.mysql.jdbc.Driver";
- }
-
public String getConnectionInitStatement(String schema) {
return null;
}
-
- public String getTrueSqlValue() {
- return "true";
- }
-
- public String getFalseSqlValue() {
- return "false";
- }
-
- public String getValidationQuery() {
- return "SELECT 1";
- }
}
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/Oracle.java b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/Oracle.java
index b8c6466d707..bbf7d935486 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/Oracle.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/Oracle.java
@@ -33,7 +33,7 @@ public class Oracle extends AbstractDialect {
public static final String ID = "oracle";
public Oracle() {
- super(ID, "oracle", "oracle");
+ super(ID, "oracle", "oracle", "oracle.jdbc.OracleDriver", "1", "0", "SELECT 1 FROM DUAL");
}
public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
@@ -58,26 +58,10 @@ public class Oracle extends AbstractDialect {
}
}
- public String getDefaultDriverClassName() {
- return "oracle.jdbc.OracleDriver";
- }
-
public String getConnectionInitStatement(String schema) {
if (StringUtils.isNotBlank(schema)) {
return "ALTER SESSION SET CURRENT_SCHEMA = \"" + schema + "\"";
}
return null;
}
-
- public String getTrueSqlValue() {
- return "1";
- }
-
- public String getFalseSqlValue() {
- return "0";
- }
-
- public String getValidationQuery() {
- return "SELECT 1 FROM DUAL";
- }
}
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/PostgreSql.java b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/PostgreSql.java
index 9460aa9051a..d14c29e0eda 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/PostgreSql.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/PostgreSql.java
@@ -32,7 +32,7 @@ public class PostgreSql extends AbstractDialect {
public static final String ID = "postgresql";
public PostgreSql() {
- super(ID, "postgre", "jdbc");
+ super(ID, "postgre", "jdbc", "org.postgresql.Driver", "true", "false", "SELECT 1");
}
public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
@@ -55,26 +55,10 @@ public class PostgreSql extends AbstractDialect {
}
}
- public String getDefaultDriverClassName() {
- return "org.postgresql.Driver";
- }
-
public String getConnectionInitStatement(String schema) {
if (StringUtils.isNotBlank(schema)) {
return "SET SEARCH_PATH TO " + schema;
}
return null;
}
-
- public String getTrueSqlValue() {
- return "true";
- }
-
- public String getFalseSqlValue() {
- return "false";
- }
-
- public String getValidationQuery() {
- return "SELECT 1";
- }
}