PolarDB-X 2.0
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
| Mode | When to use |
|---|---|
| Instance mode — current account | The PolarDB-X cluster is in the same Alibaba Cloud account as DataWorks |
| Instance mode — cross-account | The PolarDB-X cluster belongs to a different Alibaba Cloud account; access is granted via a RAM role |
| Connection string mode | A direct network address (host and port) for the cluster is available |
Property definition
Data source type:
polardbx20Supported connection modes (`ConnectionPropertiesMode`):
InstanceMode,UrlMode
Shared parameters
The following parameters apply to all three connection modes.
| Parameter | Type | Required | Description |
|---|---|---|---|
database | String | Yes | The name of the database. |
username | String | Yes | The database username. |
password | String | Yes | The password for the database user. |
envType | String | Yes | The environment type for this data source. Valid values: Dev (development tasks), Prod (production schedules). |
properties | JSON Object | No | Additional 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.
| Parameter | Type | Required | Description |
|---|---|---|---|
regionId | String | Yes | The ID of the region where the cluster is deployed. Example: cn-shanghai |
instanceId | String | Yes | The 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.
| Parameter | Type | Required | Description |
|---|---|---|---|
regionId | String | Yes | The ID of the region where the cluster is deployed. Example: cn-shanghai |
instanceId | String | Yes | The ID of the PolarDB-X cluster. Example: pc-2ze82jv51re2990g5 |
crossAccountOwnerId | String | Yes | The ID of the Alibaba Cloud account that owns the cluster. |
crossAccountRoleName | String | Yes | The 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.
| Parameter | Type | Required | Description |
|---|---|---|---|
address | Array | Yes | The 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"
}
}