ConnectionInfo - Scoped, Global

Use ConnectionInfo API to get connection attribute information through the connection and credential alias.

You can use this API in scoped applications, or within the global scope. In scoped scripts, use the sn_cc namespace identifier.

This function retrieves connection attribute information identified by the given connection and credential alias.

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 = connection.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"]);
 }

Scoped ConnectionInfo - getAttribute(String name)

Returns the value of a connection info attribute with the specified name.

Table 1. Parameters
Name Type Description
None
Table 2. Returns
Type Description
void
  // get the same values using getAttribute
  gs.info(connectionInfo.getAttribute("name"));
  gs.info(connectionInfo.getAttribute("connection_url"));

Scoped ConnectionInfo - getCredentialAttribute(String name)

Returns the value of credential attributes for a specified connection.

Table 3. Parameters
Name Type Description
None
Table 4. Returns
Type Description
void
 // get credential attributes
  gs.info(connectionInfo.getCredentialAttribute("user_name"));
  gs.info(connectionInfo.getCredentialAttribute("password")); 

Scoped ConnectionInfo - getDataMap(String)

Returns the connection attributes as a collection of key-value pairs.

Table 5. Parameters
Name Type Description
None
Table 6. Returns
Type Description
void
 // get data map
  var datamap = connectionInfo.getDataMap();
  gs.info(datamap["name"]);
  gs.info(datamap["connection_url"]);

Scoped ConnectionInfo - getExtendedAttributes(String)

Returns the extended attributes as a collection of key-value pairs.

Table 7. Parameters
Name Type Description
None
Table 8. Returns
Type Description
void
// get extended attributes
  var extendedAttributes = connection.getExtendedAttributes();  
  gs.info(extendedAttributes["name1"]);
 }