From ad7ce2db56bd0319b2e57b9cc9786ffdb3f48882 Mon Sep 17 00:00:00 2001 From: AliceXiaoLu Date: Thu, 30 Mar 2023 18:59:21 +0800 Subject: [PATCH] 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 ":" --- .../plugin/datasource/db2/param/Db2DataSourceProcessor.java | 4 ++-- .../datasource/db2/param/Db2DataSourceProcessorTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-db2/src/main/java/org/apache/dolphinscheduler/plugin/datasource/db2/param/Db2DataSourceProcessor.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-db2/src/main/java/org/apache/dolphinscheduler/plugin/datasource/db2/param/Db2DataSourceProcessor.java index 02b1bb5602..ab35f6a841 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-db2/src/main/java/org/apache/dolphinscheduler/plugin/datasource/db2/param/Db2DataSourceProcessor.java +++ b/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.setDatabase(connectionParams.getDatabase()); db2DatasourceParamDTO.setOther(connectionParams.getOther()); - db2DatasourceParamDTO.setUserName(db2DatasourceParamDTO.getUserName()); + db2DatasourceParamDTO.setUserName(connectionParams.getUser()); String[] hostSeperator = connectionParams.getAddress().split(Constants.DOUBLE_SLASH); String[] hostPortArray = hostSeperator[hostSeperator.length - 1].split(Constants.COMMA); @@ -97,7 +97,7 @@ public class Db2DataSourceProcessor extends AbstractDataSourceProcessor { public String getJdbcUrl(ConnectionParam connectionParam) { Db2ConnectionParam db2ConnectionParam = (Db2ConnectionParam) connectionParam; if (MapUtils.isNotEmpty(db2ConnectionParam.getOther())) { - return String.format("%s;%s", db2ConnectionParam.getJdbcUrl(), + return String.format("%s:%s", db2ConnectionParam.getJdbcUrl(), transformOther(db2ConnectionParam.getOther())); } return db2ConnectionParam.getJdbcUrl(); diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-db2/src/test/java/org/apache/dolphinscheduler/plugin/datasource/db2/param/Db2DataSourceProcessorTest.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-db2/src/test/java/org/apache/dolphinscheduler/plugin/datasource/db2/param/Db2DataSourceProcessorTest.java index ea04ece189..d5289afcf2 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-db2/src/test/java/org/apache/dolphinscheduler/plugin/datasource/db2/param/Db2DataSourceProcessorTest.java +++ b/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(); db2ConnectionParam.setOther(map); 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