Skip to content

Commit

Permalink
fix sql server
Browse files Browse the repository at this point in the history
  • Loading branch information
sahusanket committed Mar 18, 2024
1 parent d542a2f commit ecc337b
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 36 deletions.
2 changes: 1 addition & 1 deletion coverage-report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>io.cdap.delta</groupId>
<artifactId>database-delta-plugins</artifactId>
<version>0.10.1-SNAPSHOT</version>
<version>0.10.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion delta-plugins-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>database-delta-plugins</artifactId>
<groupId>io.cdap.delta</groupId>
<version>0.10.1-SNAPSHOT</version>
<version>0.10.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
60 changes: 30 additions & 30 deletions mysql-delta-plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>database-delta-plugins</artifactId>
<groupId>io.cdap.delta</groupId>
<version>0.10.1-SNAPSHOT</version>
<version>0.10.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -74,35 +74,35 @@
</plugin>


<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.33.0</version>
<configuration>
<images>
<image>
<name>${mysql.image}</name>
<run>
<env>
<MYSQL_ROOT_PASSWORD>${mysql.root.password}</MYSQL_ROOT_PASSWORD>
<MYSQL_ROOT_HOST>%</MYSQL_ROOT_HOST>
</env>
<ports>
<port>mysql.port:3306</port>
</ports>
<portPropertyFile>
${port.file}
</portPropertyFile>
<cmd>--server-id=1 --log_bin=mysql-bin --binlog_format=row --binlog_row_image=full</cmd>
<wait>
<log>ready for connections</log>
<time>30000</time>
</wait>
</run>
</image>
</images>
</configuration>
</plugin>
<!-- <plugin>-->
<!-- <groupId>io.fabric8</groupId>-->
<!-- <artifactId>docker-maven-plugin</artifactId>-->
<!-- <version>0.33.0</version>-->
<!-- <configuration>-->
<!-- <images>-->
<!-- <image>-->
<!-- <name>${mysql.image}</name>-->
<!-- <run>-->
<!-- <env>-->
<!-- <MYSQL_ROOT_PASSWORD>${mysql.root.password}</MYSQL_ROOT_PASSWORD>-->
<!-- <MYSQL_ROOT_HOST>%</MYSQL_ROOT_HOST>-->
<!-- </env>-->
<!-- <ports>-->
<!-- <port>mysql.port:3306</port>-->
<!-- </ports>-->
<!-- <portPropertyFile>-->
<!-- ${port.file}-->
<!-- </portPropertyFile>-->
<!-- <cmd>&#45;&#45;server-id=1 &#45;&#45;log_bin=mysql-bin &#45;&#45;binlog_format=row &#45;&#45;binlog_row_image=full</cmd>-->
<!-- <wait>-->
<!-- <log>ready for connections</log>-->
<!-- <time>30000</time>-->
<!-- </wait>-->
<!-- </run>-->
<!-- </image>-->
<!-- </images>-->
<!-- </configuration>-->
<!-- </plugin>-->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>io.cdap.delta</groupId>
<artifactId>database-delta-plugins</artifactId>
<version>0.10.1-SNAPSHOT</version>
<version>0.10.0-SNAPSHOT</version>
<modules>
<module>mysql-delta-plugins</module>
<module>delta-plugins-common</module>
Expand Down
13 changes: 12 additions & 1 deletion sqlserver-delta-plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<artifactId>database-delta-plugins</artifactId>
<groupId>io.cdap.delta</groupId>
<version>0.10.1-SNAPSHOT</version>
<version>0.10.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -46,6 +46,17 @@
</exclusion>
</exclusions>
</dependency>
<!-- In debezium 1.3.1 this was included as COMPILE scope. In new version it's added as runtime-->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>jakarta.xml.bind</groupId>-->
<!-- <artifactId>jakarta.xml.bind-api</artifactId>-->
<!-- <version>2.3.2</version>-->
<!-- </dependency>-->
<dependency>
<groupId>io.cdap.delta</groupId>
<artifactId>delta-plugins-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import io.debezium.connector.sqlserver.SourceInfo;
import io.debezium.connector.sqlserver.SqlServerConnection;
import io.debezium.connector.sqlserver.SqlServerConnector;
import io.debezium.connector.sqlserver.SqlServerConnectorConfig;
import io.debezium.connector.sqlserver.SqlServerConnectorTask;
import io.debezium.connector.sqlserver.SqlServerErrorHandler;
import io.debezium.embedded.EmbeddedEngine;
import io.debezium.jdbc.JdbcConfiguration;
Expand All @@ -39,6 +41,11 @@
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.sql.Driver;
import java.util.Arrays;
import java.util.HashSet;
Expand Down Expand Up @@ -86,8 +93,10 @@ public void start(Offset offset) {
// load sql server jdbc driver into class loader and use this loaded jdbc class to set the static factory
// variable in SqlServerConnection for instantiation purpose later on.
Class<? extends Driver> jdbcDriverClass = context.loadPluginClass(config.getJDBCPluginId());
SqlServerConnection.jdbcDriverClass = jdbcDriverClass;
SqlServerErrorHandler.driverClassLoader = jdbcDriverClass.getClassLoader();
SqlServerConnection.jdbcDriverClass = jdbcDriverClass;


// this is needed since sql server does not return the database information in the record
String databaseName = config.getDatabase();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public SqlServerConnection(JdbcConfiguration config, SourceTimestampMode sourceT
this.optionRecompile = optionRecompile;
}

private static String createUrlPattern(boolean multiPartitionMode) {
public static String createUrlPattern(boolean multiPartitionMode) {
String pattern = URL_PATTERN;
if (!multiPartitionMode) {
pattern += ";databaseName=${" + JdbcConfiguration.DATABASE + "}";
Expand Down

0 comments on commit ecc337b

Please sign in to comment.