Skip to content

Commit

Permalink
DBZ-7167 Provide a public API from the connector implementations to r…
Browse files Browse the repository at this point in the history
…etrieve the list of matching collections or tables based on the different include-/exclude lists
  • Loading branch information
harveyyue authored and jpechane committed Dec 19, 2023
1 parent 5cc586f commit e53b13b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/io/debezium/connector/db2/Db2Connector.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.debezium.connector.db2;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand All @@ -17,10 +18,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.debezium.DebeziumException;
import io.debezium.annotation.ThreadSafe;
import io.debezium.config.Configuration;
import io.debezium.connector.common.RelationalBaseSourceConnector;
import io.debezium.relational.RelationalDatabaseConnectorConfig;
import io.debezium.relational.TableId;

/**
* The main connector class used to instantiate configuration and execution classes
Expand Down Expand Up @@ -94,4 +97,17 @@ protected void validateConnection(Map<String, ConfigValue> configValues, Configu
protected Map<String, ConfigValue> validateAllFields(Configuration config) {
return config.validate(Db2ConnectorConfig.ALL_FIELDS);
}

@SuppressWarnings("unchecked")
@Override
public List<TableId> getMatchingCollections(Configuration config) {
Db2ConnectorConfig connectorConfig = new Db2ConnectorConfig(config);
try (Db2Connection connection = new Db2Connection(connectorConfig.getJdbcConfig())) {
return new ArrayList<>(
connection.readTableNames(null, null, null, new String[]{ "TABLE" }));
}
catch (SQLException e) {
throw new DebeziumException(e);
}
}
}

0 comments on commit e53b13b

Please sign in to comment.