Help Center > > Developer Guide> Demos> MySQL SDKs


Updated at: Apr 21, 2020 GMT+08:00

This topic uses a MySQL SDK-based demo application as an example to describe how to configure an application to enable connection to BCS and successful running.

This demo is used only for scenario experience and is not used in actual applications.


  1. Log in to the BCS console.

    Click Buy BCS Service in the upper right corner of the page and set the parameters.

    Table 1 Parameters



    Billing Mode

    Select Pay-per-use.


    Retain the default value.

    Service Name

    Enter demo.


    Select Basic. If Chinese cryptographic algorithms must be used, select Enterprise.

    Blockchain Type

    Select either Private or Consortium.

    Consensus Mechanism

    Select Solo.

    Resource Access Initial Password

    Enter a password.

    Confirm Password

    Enter the password again.

    Advanced Settings

    Select Configure.


    Select Create a new CCE cluster.


    Select an AZ.

    ECS Specifications

    Select the flavor of 4 vCPUs | 8 GB.

    ECS Quantity

    Enter 1.

    High Availability

    Select No.


    Select Automatically create VPC.


    Select Automatically create subnet.

    ECS Login Method

    Select Password.

    Password of Root User

    If you do not enter a password here, the previously specified resource access initial password will be used.

    Confirm Password


    Blockchain Mgmt. Initial Password

    If you do not enter a password here, the previously specified resource access initial password will be used.

    Confirm Password



    Select a 2.X.X version (corresponding to Fabric v1.1.0).


    This demo describes only the operation procedure for Fabric v1.1.0.

    Volume Type

    Select SFS Turbo.

    Peer Organization

    Change the name of the automatically created peer organization to xxx1 and the peer quantity to 2.

    Select an existing RDS instance, and use the username root and the password specified when the RDS instance was created.

    Orderer Quantity

    Retain the default value 1.

    Enable Data Aging on Orderers

    Select No.

    Security Mechanism

    Select ECDSA.


    The Chinese cryptographic algorithms option is available. If this option is selected,

    certain configurations of the demo application must be modified. Pay attention to the following descriptions.

    Storage Capacity of Peer Organization

    Retain the default value.

    Ledger Storage

    Select Relational database (MySQL).

    Channel Configuration

    The xxx1 peer organization has been added to the channel automatically. Retain this default setting.

    Enable Support for RESTful APIs

    Select No.

    Use EIP

    Select Yes.

    EIP Billed By

    Select Bandwidth.

    EIP Bandwidth

    Retain the default value.

    Configure Block Generation

    Select No.

    Click Next, confirm the configurations, and click Submit. If the status of the service and organization is Normal, the service has been successfully created.

  2. Click Manage Blockchain in the Operation column of the BCS service you just created.

    On the login page, enter the username, password, and verification code, and click Log In.

    The username is admin, and the password is the Blockchain Mgmt. Initial Password set when you bought the BCS service. If you have not set this password, use the resource access initial password.

  3. Click in the upper left corner of the page.

    The parameters for chaincode installation are as follows.



    Chaincode Name


    Chaincode Version

    Enter 1.0.

    Ledger Storage

    Select Relational database (MySQL).

    Select All Peers

    Select the checkbox.

    Organization & Peer

    Select peer-0.


    Select Golang.

    Chaincode File

    Add the downloaded chaincode file

    Chaincode Description

    Enter a description of the chaincode.

  4. After installing the chaincode, click Instantiate in the Operation column of the chaincode list.

    The parameters for chaincode instantiation are as follows.




    Select channel.

    Chaincode Version

    Select 1.0.

    Initialization Function

    Enter init.

    Chaincode Parameters

    Enter a,200,b,250.

    Endorsement Policy

    Select Endorsement from any of the following organizations.

    Endorsing Organizations

    Select xxx1.

    Privacy Protection

    Select No.

  5. Download the administrator certificates of the orderer and organization xxx1 on the Service Management page.

  6. Download and decompress the SDK configuration file.
  7. Click More > Download SDK Configuration in the Operation column on the Service Management page.

    Set the SDK file parameters.



    Chaincode Name

    Enter account.


    The chaincode name and version must be the same as those specified for chaincode installation and instantiation.

    Chaincode Version

    Enter 1.0.

    Certificate Root Path

    Specify a root path for storing certificates. In this example, the root path is src/main/fixture/chanmel.




    Retain the default value.

    Click Download and the file will be saved to the default download path of your system.

  8. Modify the downloaded SDK configuration.

    Add adminPrivateKey and signedCert, and set the path based on the certificate storage path. The following figure shows an example after the modification.

  9. Download the MySQL SDK demo package (Maven project) and import the package to Eclipse.

    Project structure description:

    • The storage path of the SDK configuration file is fixed to src/main/fixture/config.
    • The file name can be set to any value.

      In the following figure, network-config.yaml in the config directory is an SDK configuration file.

    • The peer and orderer certificates can be placed anywhere in the project, but their locations must be the same as those specified in the SDK configuration file.

      As shown in the following figure, two certificates are located in the src/main/fixture/channel directory.

  10. Save the two downloaded certificates to the directory specified by the code, and decompress them.

  11. Save the modified SDK configuration file to src/main/fixture/config.

  12. Execute under src\test\java\com\huawei\fabricsql\jdbc to transfer money.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?

Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel