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.
- Buy a BCS service. The following table lists the service parameters.
Table 2 Parameters
Retain the default value.
Select either Private or Consortium.
Select CCE cluster.
Select an existing container cluster.
Select an existing SFS file system.
Select Relational database (MySQL).
Create a peer organization named xxxx with two peers.
Select an existing RDS instance, and use the username root and the password specified when the RDS instance was created.
Select a 2.X.X version (corresponding to Fabric v1.1.0).NOTE:
This demo describes only the operation procedure for Fabric v1.1.0. If Fabric v1.4.0 is used, the demo may fail to run.
Blockchain Mgmt. Initial Password
Set a password.
Enter the password again.
Enable Support for RESTful APIs
Set it to 1.
Create a channel named demochannel, and add the peer organization xxx1 to the channel.
Click Next, confirm the configurations, and click Submit. If the status of the service and organization is Normal, the service has been successfully created.
- Go to the Blockchain Management console to install and instantiate the chaincode. The chaincode installation and instantiation dialog boxes are shown in following figures.
- Download the administrator certificates of the orderer and xxx1 organizations on the Service Management page.
- Download and decompress the SDK configuration file.
- 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.
- Import the demo package to the 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 at the src/main/fixture/channel directory.
- Save the two certificates downloaded in step 3 to the directory specified by the code, and decompress them.
- Save the SDK configuration file modified in step 5 to src/main/fixture/config.
- Execute FabricJDBCWorkflowTest.java under src\test\java\com\huawei\fabricsql\jdbc to transfer money.