Skip to content

Commit

Permalink
fix connection properties
Browse files Browse the repository at this point in the history
  • Loading branch information
whhe committed Mar 31, 2023
1 parent b66a4db commit a7e025b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ public SourceFunction<T> build() {
tableName,
tableList,
connectTimeout,
serverTimeZone,
hostname,
port,
jdbcDriver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public class OceanBaseConnection extends JdbcConnection {

private static final Properties DEFAULT_JDBC_PROPERTIES = initializeDefaultJdbcProperties();
private static final String MYSQL_URL_PATTERN =
"jdbc:mysql://${hostname}:${port}/?connectTimeout=${connectTimeout}&serverTimezone=${serverTimezone}";
"jdbc:mysql://${hostname}:${port}/?connectTimeout=${connectTimeout}";
private static final String OB_URL_PATTERN =
"jdbc:oceanbase://${hostname}:${port}/?connectTimeout=${connectTimeout}&serverTimezone=${serverTimezone}";
"jdbc:oceanbase://${hostname}:${port}/?connectTimeout=${connectTimeout}";

private String compatibleMode;

Expand All @@ -48,29 +48,22 @@ public OceanBaseConnection(
String user,
String password,
Duration timeout,
String serverTimeZone,
String jdbcDriver,
Properties jdbcProperties,
ClassLoader classLoader) {
super(
config(hostname, port, user, password, timeout, serverTimeZone),
config(hostname, port, user, password, timeout),
factory(jdbcDriver, jdbcProperties, classLoader));
}

private static Configuration config(
String hostname,
Integer port,
String user,
String password,
Duration timeout,
String serverTimeZone) {
String hostname, Integer port, String user, String password, Duration timeout) {
return Configuration.create()
.with("hostname", hostname)
.with("port", port)
.with("user", user)
.with("password", password)
.with("connectTimeout", timeout == null ? 30000 : timeout.toMillis())
.with("serverTimezone", serverTimeZone)
.build();
}

Expand All @@ -95,7 +88,7 @@ private static Properties initializeDefaultJdbcProperties() {
defaultJdbcProperties.setProperty("useInformationSchema", "true");
defaultJdbcProperties.setProperty("nullCatalogMeansCurrent", "false");
defaultJdbcProperties.setProperty("useUnicode", "true");
defaultJdbcProperties.setProperty("zeroDateTimeBehavior", "CONVERT_TO_NULL");
defaultJdbcProperties.setProperty("zeroDateTimeBehavior", "convertToNull");
defaultJdbcProperties.setProperty("characterEncoding", "UTF-8");
defaultJdbcProperties.setProperty("characterSetResults", "UTF-8");
return defaultJdbcProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public class OceanBaseRichSourceFunction<T> extends RichSourceFunction<T>
private final String tableName;
private final String tableList;
private final Duration connectTimeout;
private final String serverTimeZone;
private final String hostname;
private final Integer port;
private final String jdbcDriver;
Expand Down Expand Up @@ -112,7 +111,6 @@ public OceanBaseRichSourceFunction(
String tableName,
String tableList,
Duration connectTimeout,
String serverTimeZone,
String hostname,
Integer port,
String jdbcDriver,
Expand All @@ -130,7 +128,6 @@ public OceanBaseRichSourceFunction(
this.tableName = tableName;
this.tableList = tableList;
this.connectTimeout = checkNotNull(connectTimeout);
this.serverTimeZone = checkNotNull(serverTimeZone);
this.hostname = hostname;
this.port = port;
this.jdbcDriver = jdbcDriver;
Expand Down Expand Up @@ -188,7 +185,6 @@ private OceanBaseConnection getSnapshotConnection() throws SQLException {
username,
password,
connectTimeout,
serverTimeZone,
jdbcDriver,
jdbcProperties,
getClass().getClassLoader());
Expand Down

0 comments on commit a7e025b

Please sign in to comment.