PolarDB-X 2.0

Updated at:

Connect DataWorks to a PolarDB-X 2.0 database by configuring the data source properties for your chosen connection mode. DataWorks supports two modes: instance mode, which resolves connection details from the cluster directly, and connection string mode, which uses an explicit host and port.

Connection modes

ModeWhen to use
Instance mode — current accountThe PolarDB-X cluster is in the same Alibaba Cloud account as DataWorks
Instance mode — cross-accountThe PolarDB-X cluster belongs to a different Alibaba Cloud account; access is granted via a RAM role
Connection string modeA direct network address (host and port) for the cluster is available

Property definition

  • Data source type: polardbx20

  • Supported connection modes (`ConnectionPropertiesMode`): InstanceMode, UrlMode

Shared parameters

The following parameters apply to all three connection modes.

ParameterTypeRequiredDescription
databaseStringYesThe name of the database.
usernameStringYesThe database username.
passwordStringYesThe password for the database user.
envTypeStringYesThe environment type for this data source. Valid values: Dev (development tasks), Prod (production schedules).
propertiesJSON ObjectNoAdditional JDBC connection properties passed to the driver. Example: {"useSSL": "false"}

Instance mode — current account

Use this mode when the PolarDB-X cluster belongs to the same Alibaba Cloud account as your DataWorks workspace.

ParameterTypeRequiredDescription
regionIdStringYesThe ID of the region where the cluster is deployed. Example: cn-shanghai
instanceIdStringYesThe ID of the PolarDB-X cluster. Example: pc-2ze82jv51re2990g5

Plus the shared parameters above.

Configuration example

{
    "envType": "Prod",
    "ownerId": "1107550004253538",
    "regionId": "cn-beijing",
    "instanceId": "pxc-bjrikym49rir1s",
    "database": "my_database",
    "username": "my_username",
    "password": "my_password",
    "properties": {
        "socketTimeout": "2000"
    }
}

Instance mode — cross-account

Use this mode when the PolarDB-X cluster belongs to a different Alibaba Cloud account. The target account must grant access by creating a RAM role that your DataWorks account can assume.

ParameterTypeRequiredDescription
regionIdStringYesThe ID of the region where the cluster is deployed. Example: cn-shanghai
instanceIdStringYesThe ID of the PolarDB-X cluster. Example: pc-2ze82jv51re2990g5
crossAccountOwnerIdStringYesThe ID of the Alibaba Cloud account that owns the cluster.
crossAccountRoleNameStringYesThe name of the RAM role in the owner account that grants access. Example: cross-role

Plus the shared parameters above.

Configuration example

{
    "envType": "Prod",
    "regionId": "cn-beijing",
    "instanceId": "pxc-bjrikym49rir1s",
    "database": "my_database",
    "username": "my_username",
    "password": "my_password",
    "properties": {
        "socketTimeout": "2000"
    },
    "crossAccountOwnerId": "123123123",
    "crossAccountRoleName": "cross-role"
}

Connection string mode

Use this mode when you connect to the cluster via a direct network address instead of resolving it by instance ID.

ParameterTypeRequiredDescription
addressArrayYesThe cluster endpoint, specified as an array containing a single host-and-port object. Example: [{"host": "127.0.0.1", "port": 3306}]

Plus the shared parameters above.

Configuration example

{
    "envType": "Prod",
    "address": [
        {
            "host": "127.0.0.1",
            "port": "3306"
        }
    ],
    "database": "my_database",
    "username": "my_username",
    "password": "my_password",
    "properties": {
        "socketTimeout": "2000"
    }
}