Browse Source

fix: DB2 username can not be save (#13764)

db2's jdbcUrl should be like this "jdbc:db2://localhost:50000/sample:currentSchema=DB2INST1;characterEncoding=UTF-8;".should be ":"
3.2.0-release
AliceXiaoLu 2 years ago committed by GitHub
parent
commit
ad7ce2db56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-db2/src/main/java/org/apache/dolphinscheduler/plugin/datasource/db2/param/Db2DataSourceProcessor.java
  2. 2
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-db2/src/test/java/org/apache/dolphinscheduler/plugin/datasource/db2/param/Db2DataSourceProcessorTest.java

4
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-db2/src/main/java/org/apache/dolphinscheduler/plugin/datasource/db2/param/Db2DataSourceProcessor.java

@ -54,7 +54,7 @@ public class Db2DataSourceProcessor extends AbstractDataSourceProcessor {
Db2DataSourceParamDTO db2DatasourceParamDTO = new Db2DataSourceParamDTO(); Db2DataSourceParamDTO db2DatasourceParamDTO = new Db2DataSourceParamDTO();
db2DatasourceParamDTO.setDatabase(connectionParams.getDatabase()); db2DatasourceParamDTO.setDatabase(connectionParams.getDatabase());
db2DatasourceParamDTO.setOther(connectionParams.getOther()); db2DatasourceParamDTO.setOther(connectionParams.getOther());
db2DatasourceParamDTO.setUserName(db2DatasourceParamDTO.getUserName()); db2DatasourceParamDTO.setUserName(connectionParams.getUser());
String[] hostSeperator = connectionParams.getAddress().split(Constants.DOUBLE_SLASH); String[] hostSeperator = connectionParams.getAddress().split(Constants.DOUBLE_SLASH);
String[] hostPortArray = hostSeperator[hostSeperator.length - 1].split(Constants.COMMA); String[] hostPortArray = hostSeperator[hostSeperator.length - 1].split(Constants.COMMA);
@ -97,7 +97,7 @@ public class Db2DataSourceProcessor extends AbstractDataSourceProcessor {
public String getJdbcUrl(ConnectionParam connectionParam) { public String getJdbcUrl(ConnectionParam connectionParam) {
Db2ConnectionParam db2ConnectionParam = (Db2ConnectionParam) connectionParam; Db2ConnectionParam db2ConnectionParam = (Db2ConnectionParam) connectionParam;
if (MapUtils.isNotEmpty(db2ConnectionParam.getOther())) { if (MapUtils.isNotEmpty(db2ConnectionParam.getOther())) {
return String.format("%s;%s", db2ConnectionParam.getJdbcUrl(), return String.format("%s:%s", db2ConnectionParam.getJdbcUrl(),
transformOther(db2ConnectionParam.getOther())); transformOther(db2ConnectionParam.getOther()));
} }
return db2ConnectionParam.getJdbcUrl(); return db2ConnectionParam.getJdbcUrl();

2
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-db2/src/test/java/org/apache/dolphinscheduler/plugin/datasource/db2/param/Db2DataSourceProcessorTest.java

@ -85,7 +85,7 @@ public class Db2DataSourceProcessorTest {
.build(); .build();
db2ConnectionParam.setOther(map); db2ConnectionParam.setOther(map);
String jdbcUrl = db2DatasourceProcessor.getJdbcUrl(db2ConnectionParam); String jdbcUrl = db2DatasourceProcessor.getJdbcUrl(db2ConnectionParam);
Assertions.assertEquals("jdbc:db2://localhost:5142/default;other=other", jdbcUrl); Assertions.assertEquals("jdbc:db2://localhost:5142/default:other=other", jdbcUrl);
} }
@Test @Test

Loading…
Cancel
Save