Skip to content

don't use DatabaseDrive.MSSQL in source-mssql #35713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static io.airbyte.cdk.db.factory.DatabaseDriver.MYSQL;
import static io.airbyte.cdk.db.factory.DatabaseDriver.POSTGRESQL;

import io.airbyte.cdk.db.factory.DatabaseDriver;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.microsoft.sqlserver.jdbc.SQLServerDriver;
import io.airbyte.cdk.db.factory.DatabaseDriver;
import io.airbyte.cdk.db.jdbc.JdbcDatabase;
import io.airbyte.cdk.db.jdbc.JdbcUtils;
Expand Down Expand Up @@ -102,6 +103,7 @@
public class MssqlSource extends AbstractJdbcSource<JDBCType> implements Source {

private static final Logger LOGGER = LoggerFactory.getLogger(MssqlSource.class);
public static DatabaseDriver driver = new DatabaseDriver (SQLServerDriver.class, "jdbc:sqlserver://%s:%d;databaseName=%s");
public static final String DESCRIBE_TABLE_QUERY =
"""
sp_columns "%s"
Expand All @@ -110,7 +112,7 @@ public class MssqlSource extends AbstractJdbcSource<JDBCType> implements Source
"""
SELECT CASE WHEN (SELECT TOP 1 1 FROM "%s"."%s" WHERE "%s" IS NULL)=1 then 1 else 0 end as %s
""";
public static final String DRIVER_CLASS = DatabaseDriver.MSSQLSERVER.driverClassName();
public static final String DRIVER_CLASS = driver.driverClassName();
public static final String MSSQL_CDC_OFFSET = "mssql_cdc_offset";
public static final String MSSQL_DB_HISTORY = "mssql_db_history";
public static final String IS_COMPRESSED = "is_compressed";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ private static Database getDatabaseFromConfig(final JsonNode config) {
var dslContext = DSLContextFactory.create(
config.get(JdbcUtils.USERNAME_KEY).asText(),
config.get(JdbcUtils.PASSWORD_KEY).asText(),
DatabaseDriver.MSSQLSERVER.driverClassName(),
String.format(DatabaseDriver.MSSQLSERVER.urlFormatString(),
MssqlSource.driver.driverClassName(),
String.format(MssqlSource.driver.urlFormatString(),
config.get(JdbcUtils.HOST_KEY).asText(),
config.get(JdbcUtils.PORT_KEY).asInt(),
config.get(JdbcUtils.DATABASE_KEY).asText()) + ";encrypt=false",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected Database setupDatabase(final String dbName) {
dslContext = DSLContextFactory.create(
config.get(JdbcUtils.USERNAME_KEY).asText(),
config.get(JdbcUtils.PASSWORD_KEY).asText(),
DatabaseDriver.MSSQLSERVER.driverClassName(),
MssqlSource.driver.driverClassName(),
String.format("jdbc:sqlserver://%s:%s;databaseName=%s;",
config.get(JdbcUtils.HOST_KEY).asText(),
config.get(JdbcUtils.PORT_KEY).asInt(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public Stream<String> mssqlCmd(final Stream<String> sql) {

@Override
public DatabaseDriver getDatabaseDriver() {
return DatabaseDriver.MSSQLSERVER;
return MssqlSource.driver;
}

@Override
Expand Down