Skip to content

Commit 6bb2304

Browse files
author
dujie
committed
[oracle]#1244 Oracle URL format is inconsistent with the debezium default format
1 parent 5ee2233 commit 6bb2304

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

flink-connector-oracle-cdc/src/main/java/com/ververica/cdc/connectors/oracle/OracleSource.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,17 @@ public DebeziumSourceFunction<T> build() {
170170
props.putAll(dbzProperties);
171171
}
172172

173+
String hostname = props.getProperty("database.hostname");
174+
String port = props.getProperty("database.port");
175+
String dbname = props.getProperty("database.dbname");
176+
177+
String url;
178+
if (!props.containsKey("database.url")) {
179+
url = "jdbc:oracle:thin:@" + hostname + ":" + port + ":" + dbname;
180+
// debezium default URL format is SID rather than serviceName, so we should set url
181+
props.setProperty("database.url", url);
182+
}
183+
173184
return new DebeziumSourceFunction<>(
174185
deserializer, props, specificOffset, new OracleValidator(props));
175186
}

flink-connector-oracle-cdc/src/main/java/com/ververica/cdc/connectors/oracle/OracleValidator.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,17 @@ public void validate() {
6565

6666
public static Connection openConnection(Properties properties) throws SQLException {
6767
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
68-
String hostname = properties.getProperty("database.hostname");
69-
String port = properties.getProperty("database.port");
70-
String dbname = properties.getProperty("database.dbname");
68+
String url;
69+
if (properties.containsKey("database.url")) {
70+
url = properties.getProperty("database.url");
71+
} else {
72+
String hostname = properties.getProperty("database.hostname");
73+
String port = properties.getProperty("database.port");
74+
String dbname = properties.getProperty("database.dbname");
75+
url = "jdbc:oracle:thin:@" + hostname + ":" + port + ":" + dbname;
76+
}
7177
String userName = properties.getProperty("database.user");
7278
String userpwd = properties.getProperty("database.password");
73-
return DriverManager.getConnection(
74-
"jdbc:oracle:thin:@" + hostname + ":" + port + ":" + dbname, userName, userpwd);
79+
return DriverManager.getConnection(url, userName, userpwd);
7580
}
7681
}

0 commit comments

Comments
 (0)