#----- 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
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;
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");
@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);
}
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
@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();
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();