From ec9d7f5378d7aa117740733208860029e4f25637 Mon Sep 17 00:00:00 2001 From: sjgllgh <129264181+sjgllgh@users.noreply.github.com> Date: Mon, 23 Oct 2023 14:16:55 +0800 Subject: [PATCH] Jdbc driver is compatible with multiple versions (#4930) * Jdbc driver is compatible with multiple versions * code formatting * Update reference method --- .../apache/linkis/ujes/jdbc/LinkisSQLConnection.scala | 10 +++++++++- .../manager/label/entity/engine/EngineTypeLabel.java | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/linkis-computation-governance/linkis-jdbc-driver/src/main/scala/org/apache/linkis/ujes/jdbc/LinkisSQLConnection.scala b/linkis-computation-governance/linkis-jdbc-driver/src/main/scala/org/apache/linkis/ujes/jdbc/LinkisSQLConnection.scala index 99bb247738..93956d6535 100644 --- a/linkis-computation-governance/linkis-jdbc-driver/src/main/scala/org/apache/linkis/ujes/jdbc/LinkisSQLConnection.scala +++ b/linkis-computation-governance/linkis-jdbc-driver/src/main/scala/org/apache/linkis/ujes/jdbc/LinkisSQLConnection.scala @@ -18,6 +18,7 @@ package org.apache.linkis.ujes.jdbc import org.apache.linkis.common.utils.{Logging, Utils} +import org.apache.linkis.manager.label.builder.factory.LabelBuilderFactoryContext import org.apache.linkis.manager.label.constant.LabelKeyConstant import org.apache.linkis.manager.label.entity.engine.{EngineType, EngineTypeLabel, RunType} import org.apache.linkis.manager.label.utils.EngineTypeLabelCreator @@ -126,7 +127,14 @@ class LinkisSQLConnection(private[jdbc] val ujesClient: UJESClient, props: Prope if (params != null & params.length() > 0) { params.split(PARAM_SPLIT).map(_.split(KV_SPLIT)).foreach { case Array(k, v) if k.equals(UJESSQLDriver.ENGINE_TYPE) => - return EngineTypeLabelCreator.createEngineTypeLabel(v) + if (v.contains('-')) { + val factory = LabelBuilderFactoryContext.getLabelBuilderFactory + val label = factory.createLabel(classOf[EngineTypeLabel]) + label.setStringValue(v) + return label + } else { + return EngineTypeLabelCreator.createEngineTypeLabel(v) + } case _ => } } diff --git a/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/entity/engine/EngineTypeLabel.java b/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/entity/engine/EngineTypeLabel.java index 6e27151131..53145503e2 100644 --- a/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/entity/engine/EngineTypeLabel.java +++ b/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/entity/engine/EngineTypeLabel.java @@ -79,7 +79,7 @@ public Boolean isEmpty() { } @Override - protected void setStringValue(String stringValue) { + public void setStringValue(String stringValue) { if (StringUtils.isNotBlank(stringValue)) { try { HashMap valueMap =