ConnectionInfo - スコープ付き、グローバル

  • リリースバージョン: Zurich
  • 更新日 2025年07月31日
  • 所要時間:4分
  • ConnectionInfo API を使用すると、接続および資格情報エイリアスを介して接続属性情報を取得できます。

    この API は、スコープ対象のアプリケーションまたはグローバルスコープで使用できます。スコープ指定のスクリプトでは、sn_cc 名前空間識別子を使用します。

    接続と資格情報の詳細については、「 資格情報と接続情報」を参照してください。

    この関数は、指定された接続および資格証明エイリアスによって識別される接続属性情報を取得します。

    var provider = new sn_cc.ConnectionInfoProvider();
    
    // get a jdbc connection in the current domain with the alias ID
    //     "6219afbf9f03320021dd7501942e70fc"
    var connectionInfo = provider.getConnectionInfo("6219afbf9f03320021dd7501942e70fc");
    if (connectionInfo != null) {
      // get data map
      var datamap = connectionInfo.getDataMap();
      gs.info(datamap["name"]);
      gs.info(datamap["connection_url"]);
    
      // get the same values using getAttribute
      gs.info(connectionInfo.getAttribute("name"));
      gs.info(connectionInfo.getAttribute("connection_url"));
    
      // get credential attributes
      gs.info(connectionInfo.getCredentialAttribute("user_name"));
      gs.info(connectionInfo.getCredentialAttribute("password")); 
    
      // get extended attributes
      var extendedAttributes = connectionInfo.getExtendedAttributes();  
      gs.info(extendedAttributes["name1"]);
     }
    
     // get a jdbc connection in the ACME domain with the alias ID
     //      "cd5923ff9f03320021dd7501942e70bb"
     connectionInfo = provider.getConnectionInfoByDomain("cd5923ff9f03320021dd7501942e70bb",
            "c90d4b084a362312013398f051272c0d");
     if (connectionInfo != null) {
       // get data map
       var datamap = connectionInfo.getDataMap();
       gs.info(datamap["name"]);
     }
    

    ScopedConnectionInfo - getAttribute(String name)

    指定されたプロパティ名を持つ ConnectionInfo 属性の値を返します。

    表 : 1. パラメーター
    名前 タイプ 説明
    name 文字列 ConnectionInfo オブジェクトのプロパティの名前です。
    表 : 2. 返される内容
    タイプ 説明
    文字列 指定された ConnectionInfo プロパティの値です。
      // get the same values using getAttribute
      gs.info(connectionInfo.getAttribute("name"));
      gs.info(connectionInfo.getAttribute("connection_url"));
    

    スコープ付き ConnectionInfo - getCredentialAttribute()

    指定された接続の信任状属性の値を返します。

    表 : 3. パラメーター
    名前 タイプ 説明
    なし
    表 : 4. 返される内容
    タイプ 説明
    オブジェクト 資格情報属性のキー/値ペアのマップです。
     // get credential attributes
      gs.info(connectionInfo.getCredentialAttribute("user_name"));
      gs.info(connectionInfo.getCredentialAttribute("password")); 
    

    スコープ付き ConnectionInfo - getDataMap()

    接続属性をキーと値のペアの集合として返します。

    表 : 5. パラメーター
    名前 タイプ 説明
    なし
    表 : 6. 返される内容
    タイプ 説明
    オブジェクト 接続属性のキー/値ペアのマップです。
     // get data map
      var datamap = connectionInfo.getDataMap();
      gs.info(datamap["name"]);
      gs.info(datamap["connection_url"]);
    

    スコープ付き ConnectionInfo - getExtendedAttributes()

    拡張属性をキーと値のペアの集合として返します。

    表 : 7. パラメーター
    名前 タイプ 説明
    なし
    表 : 8. 返される内容
    タイプ 説明
    オブジェクト 拡張属性のキー/値ペアのマップです。
    // get extended attributes
      var extendedAttributes = connectionInfo.getExtendedAttributes();  
      gs.info(extendedAttributes["name1"]);
     }