Browse Source

[Fix-8281][DataSource]Mysql jdbc connect failed. (#9199)

* [Fix-8281][DataSource]Mysql jdbc connect failed.This bug occurs when MySQL has no password.

* [Fix-8281][DataSource]Mysql jdbc connect failed.This bug occurs when MySQL has no password.
3.0.0/version-upgrade
worry 3 years ago committed by GitHub
parent
commit
13cc84eb8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/client/CommonDataSourceClient.java
  2. 5
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/client/CommonDataSourceClientTest.java

8
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/client/CommonDataSourceClient.java

@ -40,7 +40,6 @@ public class CommonDataSourceClient implements DataSourceClient {
private static final Logger logger = LoggerFactory.getLogger(CommonDataSourceClient.class);
public static final String COMMON_USER = "root";
public static final String COMMON_PASSWORD = "123456";
public static final String COMMON_VALIDATION_QUERY = "select 1";
protected final BaseConnectionParam baseConnectionParam;
@ -73,19 +72,12 @@ public class CommonDataSourceClient implements DataSourceClient {
if (StringUtils.isBlank(baseConnectionParam.getUser())) {
setDefaultUsername(baseConnectionParam);
}
if (StringUtils.isBlank(baseConnectionParam.getPassword())) {
setDefaultPassword(baseConnectionParam);
}
}
protected void setDefaultUsername(BaseConnectionParam baseConnectionParam) {
baseConnectionParam.setUser(COMMON_USER);
}
protected void setDefaultPassword(BaseConnectionParam baseConnectionParam) {
baseConnectionParam.setPassword(COMMON_PASSWORD);
}
protected void checkValidationQuery(BaseConnectionParam baseConnectionParam) {
if (StringUtils.isBlank(baseConnectionParam.getValidationQuery())) {
setDefaultValidationQuery(baseConnectionParam);

5
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/client/CommonDataSourceClientTest.java

@ -70,11 +70,6 @@ public class CommonDataSourceClientTest {
PowerMockito.doNothing().when(commonDataSourceClient).setDefaultUsername(Mockito.any(BaseConnectionParam.class));
commonDataSourceClient.setDefaultUsername(baseConnectionParam);
Mockito.verify(commonDataSourceClient).setDefaultUsername(Mockito.any(BaseConnectionParam.class));
PowerMockito.doNothing().when(commonDataSourceClient).setDefaultPassword(Mockito.any(BaseConnectionParam.class));
commonDataSourceClient.setDefaultPassword(baseConnectionParam);
Mockito.verify(commonDataSourceClient).setDefaultPassword(Mockito.any(BaseConnectionParam.class));
}
@Test

Loading…
Cancel
Save