Create A Microsoft SQL Server Data Source

Updated at:

This topic describes how to create a Microsoft SQL Server data source, which enables Dataphin to read from and write to your Microsoft SQL Server database.

Prerequisites

If you want to create a data source for an Alibaba Cloud product in Dataphin, you must first add the IP address of Dataphin to the database whitelist (or security group) to enable network connectivity between the data source and Dataphin. For more information, see Data source whitelist configuration.

Permissions

Only custom global roles with the Create data source permission and users with the Super administrator, Data source administrator, Business segment architect, or Project administrator role can create data sources.

Procedure

  1. On the Dataphin homepage, choose Management Center > Data Source Management in the top navigation bar.

  2. On the Data Source page, click + New Data Source.

  3. On the New Data Source page, in the Relational databases section, select Microsoft SQL Server.

    If you have recently used Microsoft SQL Server, you can select it from the Recently used section or find it by using the search box.

  4. On the New Microsoft SQL Server data source page, configure the connection parameters for the data source.

    1. Configure basic data source information.

      Parameter

      Description

      Data source name

      Enter a name for the data source. The name must meet the following requirements:

      • Can contain only Chinese characters, letters, digits, underscores (_), and hyphens (-).

      • Cannot exceed 64 characters in length.

      Data source code

      After you configure the data source code, you can use thedata_source_code.table_name or data_source_code.schema.table_name format to directly access tables in the Dataphin data source from Flink SQL tasks or the Dataphin JDBC client. To automatically switch data sources based on the task execution environment, use the variable format ${data_source_code}.table or ${data_source_code}.schema.table. For more information, see Develop Flink SQL tasks.

      Important
      • The data source code cannot be modified after it is configured.

      • You can preview data on the object details page in the asset directory and asset checklist only after the data source code is configured.

      • In Flink SQL, only MySQL, Hologres, MaxCompute, Oracle, StarRocks, Hive, SelectDB, and GaussDB data warehouse service (DWS) data sources are currently supported.

      Version

      Select the version of Microsoft SQL Server. The default is SQL Server 2008. You can select SQL Server 2008 or SQL Server 2012 or later.

      Data source description

      Enter a brief description for the data source, up to 128 characters.

      Time zone

      Dataphin uses the selected time zone to process time-based data in integration tasks. The default time zone is Asia/Shanghai. Click Modify to select a different time zone. The available options are:

      • GMT: GMT-12:00, GMT-11:00, GMT-10:00, GMT-09:30, GMT-09:00, GMT-08:00, GMT-07:00, GMT-06:00, GMT-05:00, GMT-04:00, GMT-03:00, GMT-03:00, GMT-02:30, GMT-02:00, GMT-01:00, GMT+00:00, GMT+01:00, GMT+02:00, GMT+03:00, GMT+03:30, GMT+04:00, GMT+04:30, GMT+05:00, GMT+05:30, GMT+05:45, GMT+06:00, GMT+06:30, GMT+07:00, GMT+08:00, GMT+08:45, GMT+09:00, GMT+09:30, GMT+10:00, GMT+10:30, GMT+11:00, GMT+12:00, GMT+12:45, GMT+13:00, GMT+14:00.

      • Daylight Saving Time: Africa/Cairo, America/Chicago, America/Denver, America/Los_Angeles, America/New_York, America/Sao_Paulo, Asia/Bangkok, Asia/Dubai, Asia/Kolkata, Asia/Shanghai, Asia/Tokyo, Atlantic/Azores, Australia/Sydney, Europe/Berlin, Europe/London, Europe/Moscow, Europe/Paris, Pacific/Auckland, Pacific/Honolulu.

      Data source configuration

      Select the data source environment to configure:

      • If you separate your business data into production and development environments, select Production + development data source.

      • If you do not separate your business data into different environments, select Production data source.

      Tags

      Add tags to classify the data source. For information about how to create a tag, see Manage data source tags.

    2. Configure connection parameters.

      If you selected Production + development data source for Data source configuration, you must configure connection information for both the production and development environments. If you selected Production data source, you only need to configure connection information for the production environment.

      Note

      Typically, you should configure the production and development data sources as separate databases to isolate the environments and reduce the impact of development activities. However, Dataphin also lets you use the same database for both by entering identical parameter values.

      For Configuration Method, select either JDBC URL or Host. JDBC URL is the default.

      JDBC URL

      Parameter

      Description

      JDBC URL

      The format of the connection URL is jdbc:sqlserver://host:port/dbname.

      Schema

      Enter the schema associated with the username.

      Username, Password

      Enter the username and password for the target database.

      SSL Encryption

      Select whether to connect to the database by using SSL encryption. The default is Disable. You can select Disable or Enable. If you enable this option, you must configure Certificate Verification. Enabling SSL encrypts data in transit and is suitable for scenarios with high data security requirements, but it may impact connection performance. If the database is in a trusted environment, such as an internal network, you can leave this option disabled.

      Note
      • Only SQL Server 2012 or later data sources support SSL encryption. If you enable SSL encryption for a SQL Server 2008 data source, the configuration cannot be saved. You must either switch the version or disable SSL encryption.

      • If you manually specify SSL-related parameters such as encrypt or trustServerCertificate in the JDBC URL or host configuration parameters, the form settings for SSL Encryption and Certificate Verification override them in the event of a conflict.

      Certificate Verification

      Select whether to verify the server certificate. The default is Do not verify server certificate. You can select Do not verify server certificate or Verify server certificate. If you select Verify server certificate, Dataphin validates the server's certificate chain and hostname. You must configure the CA certificate file and can also configure the Certificate password and Certificate hostname. Verifying the server certificate helps prevent man-in-the-middle attacks and ensures a trusted connection, making it suitable for high-security scenarios such as security audits. Skipping verification simplifies setup and is suitable for trusted environments like internal networks.

      CA certificate file

      Required when you select Verify server certificate. Upload the CA certificate file used to validate the server certificate chain and hostname. Only .jks truststore files are supported. The file size cannot exceed 2 MB. You must convert files in other formats, such as .cer, .crt, .pem, or .pfx, to the JKS truststore format before uploading. For security reasons, you cannot download the certificate file after uploading it. Keep a local copy of your certificate file.

      Certificate password (Optional)

      Enter the password for the uploaded JKS truststore. Dataphin stores the password in encrypted form.

      Certificate hostname (Optional)

      Enter the hostname of the server certificate, for example, sqlserver.example.com. If you leave this blank, the connection address is used by default for hostname verification.

      Type

      You can select Directly connected database, Alibaba Cloud database, or Self-managed database on ECS (VPC) based on your database type and business requirements.

      • Directly connected database: Connects to the database directly through the default or a registered scheduling cluster. This method is suitable for the following scenarios: ① internet-facing databases, and ② databases in the same network environment as a registered scheduling cluster. If you need to add an access whitelist, add the internet egress IP address of the Dataphin default scheduling cluster: 47.102.192.174.

      • Alibaba Cloud database: A database purchased on Alibaba Cloud. You can connect by using a VPC proxy or Direct connection.

        • VPC proxy: If your database is an Alibaba Cloud database in a VPC, add the CIDR block 100.104.0.0/16 to its IP whitelist.

          • Region: The region where your database is located. This must be the same region as your Dataphin instance. For example, if your Dataphin instance is in the China (Shanghai) region, you can only select China (Shanghai).

          • VPC ID: Enter the ID of the VPC where the database is located. You can find this ID in the VPC console. See the following figure:

            image..png

          • VPC instance ID: Enter the database's VPC instance ID (VpcCloudInstanceId). You can obtain this ID by calling the DescribeDrdsInstance API. For more information, see DescribeDrdsInstance.

        • Direct connection: Connects to the database directly through the default or a registered scheduling cluster. If you need to add an access whitelist, add the internet egress IP address of the Dataphin default scheduling cluster: 47.102.192.174.

      • Self-managed database on ECS (VPC): A database that you have set up on an Alibaba Cloud ECS instance. You can connect to it through a VPC. To connect to the database over a VPC, configure the following information:

        • Region: The region where the database is located. This must be the same region as your Dataphin instance. For example, if your Dataphin instance is in the China (Shanghai) region, you can only select China (Shanghai).

        • VPC ID: Enter the ID of the VPC where the ECS instance is located. You can find this ID in the VPC console.

        • ECS ID: Enter the ID of the ECS instance where the database is deployed. You can find this ID in the ECS console.

      Host

      • Host configuration

        Parameter

        Description

        Server address

        Enter the IP address and port number of the server.

        You can click + Add to add multiple IP addresses and port numbers. Click the image icon to remove extra entries, but you must keep at least one.

        dbname

        Enter the name of the database.

      • Parameter configuration

        Parameter

        Description

        Parameter

        • Parameter name: You can only select an existing parameter name.

        • Parameter value: This parameter is required if a parameter name is selected. The value can contain only letters, digits, periods (.), underscores (_), and hyphens (-), and can be up to 256 characters long.

        Note

        You can click + Add Parameter to add more parameters and click the image icon to remove them. You can add up to 30 parameters.

        Schema

        Enter the schema associated with the username.

        Username, Password

        The username and password used to log on to the Microsoft SQL Server instance.

        SSL Encryption

        Select whether to connect to the database by using SSL encryption. The default is Disable. You can select Disable or Enable. If you enable this option, you must configure Certificate Verification. Enabling SSL encrypts data in transit and is suitable for scenarios with high data security requirements, but it may impact connection performance. If the database is in a trusted environment, such as an internal network, you can leave this option disabled.

        Note
        • Only SQL Server 2012 or later data sources support SSL encryption. If you enable SSL encryption for a SQL Server 2008 data source, the configuration cannot be saved. You must either switch the version or disable SSL encryption.

        • If you manually specify SSL-related parameters such as encrypt or trustServerCertificate in the JDBC URL or host configuration parameters, the form settings for SSL Encryption and Certificate Verification override them in the event of a conflict.

        Certificate Verification

        Select whether to verify the server certificate. The default is Do not verify server certificate. You can select Do not verify server certificate or Verify server certificate. If you select Verify server certificate, Dataphin validates the server's certificate chain and hostname. You must configure the CA certificate file and can also configure the Certificate password and Certificate hostname. Verifying the server certificate helps prevent man-in-the-middle attacks and ensures a trusted connection, making it suitable for high-security scenarios such as security audits. Skipping verification simplifies setup and is suitable for trusted environments like internal networks.

        CA certificate file

        Required when you select Verify server certificate. Upload the CA certificate file used to validate the server certificate chain and hostname. Only .jks truststore files are supported. The file size cannot exceed 2 MB. You must convert files in other formats, such as .cer, .crt, .pem, or .pfx, to the JKS truststore format before uploading. For security reasons, you cannot download the certificate file after uploading it. Keep a local copy of your certificate file.

        Certificate password (Optional)

        Enter the password for the uploaded JKS truststore. Dataphin stores the password in encrypted form.

        Certificate hostname (Optional)

        Enter the hostname of the server certificate, for example, sqlserver.example.com. If you leave this blank, the connection address is used by default for hostname verification.

      Note
      • If you configure the instanceName parameter, it takes precedence, and the configured port is ignored.

      • If you create a data source by using the host configuration method and then switch to the JDBC URL configuration method, Dataphin automatically populates the JDBC URL by concatenating the server's IP address and port.

    3. Configure advanced data source settings.

      Parameter

      Description

      loginTimeout

      The database login timeout, in seconds. The default is 900 seconds (15 minutes).

      Note
      • If you include a loginTimeout setting in the JDBC URL, the value in the JDBC URL is used.

      • For data sources created before Dataphin V3.11, the default loginTimeout is -1, which means no timeout.

      socketTimeout

      The database socket timeout, in milliseconds. The default is 1,800,000 milliseconds (30 minutes).

      Note
      • If you include a socketTimeout setting in the JDBC URL, the value in the JDBC URL is used.

      • For data sources created before Dataphin V3.11, the default socketTimeout is -1, which means no timeout.

      Connection retries

      The number of times Dataphin automatically retries a timed-out connection. If all retries fail, the connection attempt is marked as failed.

      Note
      • The default is 1 retry. You can set this parameter to a value from 0 to 10.

      • The connection retry count applies by default to batch integration tasks and global quality checks (requires the Asset Quality feature module). You can configure task-level retries separately in batch integration tasks.

    Note

    The following rules determine the value of a duplicate parameter if it is configured in multiple places:

    • If a parameter is set in the JDBC URL, Advanced settings, and Host configuration, the value in the JDBC URL takes precedence.

    • If a parameter is set in both the JDBC URL and Advanced settings, the value in the JDBC URL takes precedence.

    • If a parameter is set in both the Advanced settings and the Host configuration, the value in the Advanced settings takes precedence.

  5. Select a Default resource group. This resource group runs tasks related to the data source, such as executing SQL, performing batch database migrations, and previewing data.

  6. Click Test Connection or click OK to save the configuration and create the Microsoft SQL Server data source.

    Clicking Test Connection prompts Dataphin to test the connection to the data source. If you click OK directly, the system automatically tests the connection for all selected clusters. You can still create the data source even if the connection test fails for all selected clusters.

    Test Connection tests the connection for the Public Scheduling Cluster or Registered Scheduling Clusters that have been registered in Dataphin and are in normal use. The Public Scheduling Cluster is selected by default and cannot be deselected. If there are no resource groups under a Registered Scheduling Cluster, connection testing is not supported. You need to create a resource group first before testing the connection.

    • The selected clusters are used only to test network connectivity and are not used for running tasks.

    • The test connection usually completes within 2 minutes. If it times out, click the image icon to view the reason and retry.

    • Regardless of the test result (Connection Failed, Connection Successful, or Succeeded With Warning), the system records the timestamp of the final result.

      Note

      Only the test results for the Public Scheduling Cluster include three connection statuses: Succeeded With Warning, Connection Successful, and Connection Failed. The test results for Registered Scheduling Clusters in Dataphin only include two connection statuses: Connection Successful and Connection Failed.

    • When the test result is Connection Failed, click the image icon to view the failure reason.

    • When the test result is Succeeded With Warning, the application cluster connection succeeded but the scheduling cluster connection failed. The data source cannot be used for data development and integration. Click the image icon to view the log information.

    Important