This is an automated email from the ASF dual-hosted git repository.

casion pushed a commit to branch dev-1.4.0
in repository https://gitbox.apache.org/repos/asf/linkis.git


The following commit(s) were added to refs/heads/dev-1.4.0 by this push:
     new 7b1419d4b [fix-4653]fix jdbc connection cache error (#4654)
7b1419d4b is described below

commit 7b1419d4b80b1a417ca628d23588ec2b8a4c4177
Author: aiceflower <[email protected]>
AuthorDate: Mon Jun 19 09:46:39 2023 +0800

    [fix-4653]fix jdbc connection cache error (#4654)
    
    * fix jdbc connection cache
    
    * Modify the nonnull judgment
    
    * Update JDBCEngineConnExecutor.scala
    
    add annotation
---
 .../engineplugin/jdbc/executor/JDBCEngineConnExecutor.scala    | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git 
a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executor/JDBCEngineConnExecutor.scala
 
b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executor/JDBCEngineConnExecutor.scala
index 511a626c8..336d1197f 100644
--- 
a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executor/JDBCEngineConnExecutor.scala
+++ 
b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executor/JDBCEngineConnExecutor.scala
@@ -115,7 +115,15 @@ class JDBCEngineConnExecutor(override val 
outputPrintLimit: Int, val id: Int)
     var resultSet: ResultSet = null
     logger.info(s"The data source properties is $properties")
     Utils.tryCatch({
-      val dataSourceIdentifier = s"$dataSourceName-$dataSourceMaxVersionId"
+      /* url + user as the cache key */
+      val jdbcUrl: String = properties.get(JDBCEngineConnConstant.JDBC_URL)
+      val execUser: String = 
properties.get(JDBCEngineConnConstant.JDBC_SCRIPTS_EXEC_USER)
+      val proxyUser: String = 
properties.get(JDBCEngineConnConstant.JDBC_PROXY_USER_PROPERTY)
+      var dataSourceIdentifier = s"$jdbcUrl-$execUser-$proxyUser"
+      /* If datasource is used, use datasource name as the cache key */
+      if (StringUtils.isNotBlank(dataSourceName)) {
+        dataSourceIdentifier = s"$dataSourceName-$dataSourceMaxVersionId"
+      }
       connection = connectionManager.getConnection(dataSourceIdentifier, 
properties)
       logger.info("The jdbc connection has created successfully!")
     }) { e: Throwable =>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to