def getJdbcConf()

in streampark-common/src/main/scala/org/apache/streampark/common/util/ConfigUtils.scala [85:112]


  def getJdbcConf(parameter: JavaMap[String, String], alias: String = ""): Properties = {
    val prefix = alias match {
      case "" | null => KEY_JDBC_PREFIX
      case other => s"$KEY_JDBC_PREFIX$other".replaceFirst("\\.+$|$", ".")
    }
    val driver = parameter.toMap.getOrDefault(s"$prefix$KEY_JDBC_DRIVER", null)
    val url = parameter.toMap.getOrDefault(s"$prefix$KEY_JDBC_URL", null)
    val user = parameter.toMap.getOrDefault(s"$prefix$KEY_JDBC_USER", null)
    val password =
      parameter.toMap.getOrDefault(s"$prefix$KEY_JDBC_PASSWORD", null)

    (driver, url, user, password) match {
      case (x, y, _, _) if x == null || y == null =>
        throw new IllegalArgumentException(
          s"Jdbc instance:$prefix error,[driver|url] must not be null")
      case (_, _, x, y) if (x != null && y == null) || (x == null && y != null) =>
        throw new IllegalArgumentException(
          "Jdbc instance:" + prefix + " error, [user|password] must be all null,or all not null ")
      case _ =>
    }
    val param: ScalaMap[String, String] = filterParam(parameter, prefix)
    val properties = new Properties()
    val aliasName = if (alias == null || alias.trim == "") "default" else alias
    properties.put(KEY_ALIAS, aliasName)
    properties.put(KEY_JDBC_DRIVER, driver)
    param.foreach(x => properties.put(x._1, x._2))
    properties
  }