DBZ-2423 Support default port in JDBC driver
This commit is contained in:
parent
2b87e8e453
commit
43995a1b06
@ -90,7 +90,8 @@ public class Db2Connection extends JdbcConnection {
|
||||
|
||||
private static final ConnectionFactory FACTORY = JdbcConnection.patternBasedFactory(URL_PATTERN,
|
||||
DB2Driver.class.getName(),
|
||||
Db2Connection.class.getClassLoader());
|
||||
Db2Connection.class.getClassLoader(),
|
||||
JdbcConfiguration.PORT.withDefault(Db2ConnectorConfig.PORT.defaultValueAsString()));
|
||||
|
||||
/**
|
||||
* actual name of the database, which could differ in casing from the database name given in the connector config.
|
||||
|
@ -41,6 +41,8 @@
|
||||
*/
|
||||
public class Db2ConnectorConfig extends HistorizedRelationalDatabaseConnectorConfig {
|
||||
|
||||
protected static final int DEFAULT_PORT = 50000;
|
||||
|
||||
/**
|
||||
* The set of predefined SnapshotMode options or aliases.
|
||||
*/
|
||||
@ -198,6 +200,38 @@ public static SnapshotIsolationMode parse(String value, String defaultValue) {
|
||||
}
|
||||
}
|
||||
|
||||
public static final Field HOSTNAME = Field.create(DATABASE_CONFIG_PREFIX + JdbcConfiguration.HOSTNAME)
|
||||
.withDisplayName("Hostname")
|
||||
.withType(Type.STRING)
|
||||
.withWidth(Width.MEDIUM)
|
||||
.withImportance(Importance.HIGH)
|
||||
.withValidation(Field::isRequired)
|
||||
.withDescription("Resolvable hostname or IP address of the Db2 database server.");
|
||||
|
||||
public static final Field PORT = Field.create(DATABASE_CONFIG_PREFIX + JdbcConfiguration.PORT)
|
||||
.withDisplayName("Port")
|
||||
.withType(Type.INT)
|
||||
.withWidth(Width.SHORT)
|
||||
.withDefault(DEFAULT_PORT)
|
||||
.withImportance(Importance.HIGH)
|
||||
.withValidation(Field::isInteger)
|
||||
.withDescription("Port of the Db2 database server.");
|
||||
|
||||
public static final Field USER = Field.create(DATABASE_CONFIG_PREFIX + JdbcConfiguration.USER)
|
||||
.withDisplayName("User")
|
||||
.withType(Type.STRING)
|
||||
.withWidth(Width.SHORT)
|
||||
.withImportance(Importance.HIGH)
|
||||
.withValidation(Field::isRequired)
|
||||
.withDescription("Name of the Db2 database user to be used when connecting to the database.");
|
||||
|
||||
public static final Field PASSWORD = Field.create(DATABASE_CONFIG_PREFIX + JdbcConfiguration.PASSWORD)
|
||||
.withDisplayName("Password")
|
||||
.withType(Type.PASSWORD)
|
||||
.withWidth(Width.SHORT)
|
||||
.withImportance(Importance.HIGH)
|
||||
.withDescription("Password of the Db2 database user to be used when connecting to the database.");
|
||||
|
||||
public static final Field SERVER_NAME = RelationalDatabaseConnectorConfig.SERVER_NAME
|
||||
.withValidation(CommonConnectorConfig::validateServerNameIsDifferentFromHistoryTopicName);
|
||||
|
||||
@ -238,6 +272,10 @@ public static SnapshotIsolationMode parse(String value, String defaultValue) {
|
||||
* The set of {@link Field}s defined as part of this configuration.
|
||||
*/
|
||||
public static Field.Set ALL_FIELDS = Field.setOf(
|
||||
HOSTNAME,
|
||||
PORT,
|
||||
USER,
|
||||
PASSWORD,
|
||||
SERVER_NAME,
|
||||
DATABASE_NAME,
|
||||
SNAPSHOT_MODE,
|
||||
@ -261,7 +299,7 @@ public static SnapshotIsolationMode parse(String value, String defaultValue) {
|
||||
public static ConfigDef configDef() {
|
||||
ConfigDef config = new ConfigDef();
|
||||
|
||||
Field.group(config, "DB2 Server", SERVER_NAME, DATABASE_NAME, SNAPSHOT_MODE);
|
||||
Field.group(config, "DB2 Server", HOSTNAME, PORT, USER, PASSWORD, SERVER_NAME, DATABASE_NAME, SNAPSHOT_MODE);
|
||||
Field.group(config, "History Storage", KafkaDatabaseHistory.BOOTSTRAP_SERVERS,
|
||||
KafkaDatabaseHistory.TOPIC, KafkaDatabaseHistory.RECOVERY_POLL_ATTEMPTS,
|
||||
KafkaDatabaseHistory.RECOVERY_POLL_INTERVAL_MS, HistorizedRelationalDatabaseConnectorConfig.DATABASE_HISTORY);
|
||||
|
@ -39,6 +39,40 @@ public class OracleConnectorConfig extends HistorizedRelationalDatabaseConnector
|
||||
// TODO pull up to RelationalConnectorConfig
|
||||
public static final String DATABASE_CONFIG_PREFIX = "database.";
|
||||
|
||||
protected static final int DEFAULT_PORT = 1528;
|
||||
|
||||
public static final Field HOSTNAME = Field.create(DATABASE_CONFIG_PREFIX + JdbcConfiguration.HOSTNAME)
|
||||
.withDisplayName("Hostname")
|
||||
.withType(Type.STRING)
|
||||
.withWidth(Width.MEDIUM)
|
||||
.withImportance(Importance.HIGH)
|
||||
.withValidation(Field::isRequired)
|
||||
.withDescription("Resolvable hostname or IP address of the Oracle database server.");
|
||||
|
||||
public static final Field PORT = Field.create(DATABASE_CONFIG_PREFIX + JdbcConfiguration.PORT)
|
||||
.withDisplayName("Port")
|
||||
.withType(Type.INT)
|
||||
.withWidth(Width.SHORT)
|
||||
.withDefault(DEFAULT_PORT)
|
||||
.withImportance(Importance.HIGH)
|
||||
.withValidation(Field::isInteger)
|
||||
.withDescription("Port of the Oracle database server.");
|
||||
|
||||
public static final Field USER = Field.create(DATABASE_CONFIG_PREFIX + JdbcConfiguration.USER)
|
||||
.withDisplayName("User")
|
||||
.withType(Type.STRING)
|
||||
.withWidth(Width.SHORT)
|
||||
.withImportance(Importance.HIGH)
|
||||
.withValidation(Field::isRequired)
|
||||
.withDescription("Name of the Oracle database user to be used when connecting to the database.");
|
||||
|
||||
public static final Field PASSWORD = Field.create(DATABASE_CONFIG_PREFIX + JdbcConfiguration.PASSWORD)
|
||||
.withDisplayName("Password")
|
||||
.withType(Type.PASSWORD)
|
||||
.withWidth(Width.SHORT)
|
||||
.withImportance(Importance.HIGH)
|
||||
.withDescription("Password of the Oracle database user to be used when connecting to the database.");
|
||||
|
||||
public static final Field DATABASE_NAME = Field.create(DATABASE_CONFIG_PREFIX + JdbcConfiguration.DATABASE)
|
||||
.withDisplayName("Database name")
|
||||
.withType(Type.STRING)
|
||||
@ -95,6 +129,10 @@ public class OracleConnectorConfig extends HistorizedRelationalDatabaseConnector
|
||||
* The set of {@link Field}s defined as part of this configuration.
|
||||
*/
|
||||
public static Field.Set ALL_FIELDS = Field.setOf(
|
||||
HOSTNAME,
|
||||
PORT,
|
||||
USER,
|
||||
PASSWORD,
|
||||
SERVER_NAME,
|
||||
DATABASE_NAME,
|
||||
PDB_NAME,
|
||||
@ -138,7 +176,7 @@ public OracleConnectorConfig(Configuration config) {
|
||||
public static ConfigDef configDef() {
|
||||
ConfigDef config = new ConfigDef();
|
||||
|
||||
Field.group(config, "Oracle", SERVER_NAME, DATABASE_NAME, PDB_NAME,
|
||||
Field.group(config, "Oracle", HOSTNAME, PORT, USER, PASSWORD, SERVER_NAME, DATABASE_NAME, PDB_NAME,
|
||||
XSTREAM_SERVER_NAME, SNAPSHOT_MODE);
|
||||
Field.group(config, "History Storage", KafkaDatabaseHistory.BOOTSTRAP_SERVERS,
|
||||
KafkaDatabaseHistory.TOPIC, KafkaDatabaseHistory.RECOVERY_POLL_ATTEMPTS,
|
||||
|
Loading…
Reference in New Issue
Block a user