diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-03-17 16:54:54 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-09-17 14:54:23 +0200 |
commit | 530478f620406f535bd3055f88fab4edaa7da1c5 (patch) | |
tree | 3da0d8b7f6edf23bd926dcf6388606e55a1c7a6d | |
parent | f539acd2e2813f514fcb7fee08056f7fd8021bf5 (diff) | |
download | sonarqube-530478f620406f535bd3055f88fab4edaa7da1c5.tar.gz sonarqube-530478f620406f535bd3055f88fab4edaa7da1c5.zip |
SONAR-6552 Replace jTDS by Microsoft JDBC driver 4.1
6 files changed, 16 insertions, 13 deletions
diff --git a/sonar-application/src/main/assembly/conf/sonar.properties b/sonar-application/src/main/assembly/conf/sonar.properties index c4ac178e12b..e9626756fff 100644 --- a/sonar-application/src/main/assembly/conf/sonar.properties +++ b/sonar-application/src/main/assembly/conf/sonar.properties @@ -43,9 +43,8 @@ #----- Microsoft SQLServer 2008/2012 -# Only the bundled jTDS driver is supported. # Collation must be case-sensitive (CS) and accent-sensitive (AS). -#sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor +#sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=sonar #----- Connection pool settings diff --git a/sonar-application/src/main/assembly/lib/jdbc/mssql/sqljdbc41.jar b/sonar-application/src/main/assembly/lib/jdbc/mssql/sqljdbc41.jar Binary files differnew file mode 100644 index 00000000000..5cb586c83cd --- /dev/null +++ b/sonar-application/src/main/assembly/lib/jdbc/mssql/sqljdbc41.jar diff --git a/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java b/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java index 7794cb745b1..54fc71545b8 100644 --- a/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java +++ b/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java @@ -34,7 +34,7 @@ import org.sonar.process.Props; public class JdbcSettings { enum Provider { - H2("lib/jdbc/h2"), JTDS("lib/jdbc/jtds"), MYSQL("lib/jdbc/mysql"), ORACLE("extensions/jdbc-driver/oracle"), + H2("lib/jdbc/h2"), SQLSERVER("lib/jdbc/mssql"), MYSQL("lib/jdbc/mysql"), ORACLE("extensions/jdbc-driver/oracle"), POSTGRESQL("lib/jdbc/postgresql"); final String path; diff --git a/sonar-application/src/test/java/org/sonar/application/JdbcSettingsTest.java b/sonar-application/src/test/java/org/sonar/application/JdbcSettingsTest.java index 9e809a2aeab..eb418f9f405 100644 --- a/sonar-application/src/test/java/org/sonar/application/JdbcSettingsTest.java +++ b/sonar-application/src/test/java/org/sonar/application/JdbcSettingsTest.java @@ -46,10 +46,10 @@ public class JdbcSettingsTest { assertThat(settings.driverProvider("jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance")) .isEqualTo(JdbcSettings.Provider.MYSQL); try { - settings.driverProvider("jdbc:sqlserver://localhost"); + settings.driverProvider("jdbc:microsoft:sqlserver://localhost"); fail(); } catch (MessageException e) { - assertThat(e).hasMessage("Unsupported JDBC driver provider: sqlserver"); + assertThat(e).hasMessage("Unsupported JDBC driver provider: microsoft"); } try { settings.driverProvider("oracle:thin:@localhost/XE"); @@ -118,11 +118,11 @@ public class JdbcSettingsTest { @Test public void check_mssql() throws Exception { File home = temp.newFolder(); - File driverFile = new File(home, "lib/jdbc/jtds/jtds.jar"); + File driverFile = new File(home, "lib/jdbc/mssql/sqljdbc4.jar"); FileUtils.touch(driverFile); Props props = new Props(new Properties()); - props.set("sonar.jdbc.url", "jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor"); + props.set("sonar.jdbc.url", "jdbc:sqlserver://localhost/sonar;SelectMethod=Cursor"); settings.checkAndComplete(home, props); assertThat(props.nonNullValueAsFile(ProcessProperties.JDBC_DRIVER_PATH)).isEqualTo(driverFile); } diff --git a/sonar-db/src/main/java/org/sonar/db/dialect/MsSql.java b/sonar-db/src/main/java/org/sonar/db/dialect/MsSql.java index d55139113c2..27443bf49a1 100644 --- a/sonar-db/src/main/java/org/sonar/db/dialect/MsSql.java +++ b/sonar-db/src/main/java/org/sonar/db/dialect/MsSql.java @@ -26,13 +26,12 @@ public class MsSql extends AbstractDialect { public static final String ID = "mssql"; public MsSql() { - super(ID, "sqlserver", "net.sourceforge.jtds.jdbc.Driver", "1", "0", "SELECT 1"); + super(ID, "sqlserver", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "1", "0", "SELECT 1"); } @Override public boolean matchesJdbcURL(String jdbcConnectionURL) { - return StringUtils.startsWithIgnoreCase(jdbcConnectionURL, "jdbc:microsoft:sqlserver:") - || StringUtils.startsWithIgnoreCase(jdbcConnectionURL, "jdbc:jtds:sqlserver:"); + return StringUtils.startsWithIgnoreCase(jdbcConnectionURL, "jdbc:sqlserver:"); } @Override diff --git a/sonar-db/src/test/java/org/sonar/db/dialect/MsSqlTest.java b/sonar-db/src/test/java/org/sonar/db/dialect/MsSqlTest.java index 3b1ebb14989..f1159fc153c 100644 --- a/sonar-db/src/test/java/org/sonar/db/dialect/MsSqlTest.java +++ b/sonar-db/src/test/java/org/sonar/db/dialect/MsSqlTest.java @@ -29,8 +29,7 @@ public class MsSqlTest { @Test public void matchesJdbcURL() { - assertThat(msSql.matchesJdbcURL("jdbc:jtds:sqlserver://localhost;databaseName=SONAR;SelectMethod=Cursor")).isTrue(); - assertThat(msSql.matchesJdbcURL("jdbc:microsoft:sqlserver://localhost:1433;databasename=sonar")).isTrue(); + assertThat(msSql.matchesJdbcURL("jdbc:sqlserver://localhost:1433;databasename=sonar")).isTrue(); assertThat(msSql.matchesJdbcURL("jdbc:hsql:foo")).isFalse(); assertThat(msSql.matchesJdbcURL("jdbc:mysql:foo")).isFalse(); @@ -46,11 +45,17 @@ public class MsSqlTest { public void should_configure() { assertThat(msSql.getId()).isEqualTo("mssql"); assertThat(msSql.getActiveRecordDialectCode()).isEqualTo("sqlserver"); - assertThat(msSql.getDefaultDriverClassName()).isEqualTo("net.sourceforge.jtds.jdbc.Driver"); + assertThat(msSql.getDefaultDriverClassName()).isEqualTo("com.microsoft.sqlserver.jdbc.SQLServerDriver"); assertThat(msSql.getValidationQuery()).isEqualTo("SELECT 1"); } @Test + public void do_not_support_jtds_since_5_2() throws Exception { + assertThat(msSql.matchesJdbcURL("jdbc:jtds:sqlserver://localhost;databaseName=SONAR;SelectMethod=Cursor")).isFalse(); + + } + + @Test public void msSql_does_supportMigration() { assertThat(msSql.supportsMigration()).isTrue(); } |