今すぐお試しください!

製品の詳細CData FireDAC Components for IBM Cloud Object Storage を確認して、無償評価版をダウンロード:

今すぐダウンロード

Build a Simple VCL Application for IBM Cloud Object Storage Data

How to build a simple VCL Application to view IBM Cloud Object Storage data in RAD Studio using the CData FireDAC Components for IBM Cloud Object Storage.

Embarcadero RAD Studio provides a development environment for Delphi and C++Builder applications. With the CData FireDAC Components for IBM Cloud Object Storage, you gain access to live IBM Cloud Object Storage data within RAD Studio, abstracting the data into tables, views, and stored procedures that can be used to both retrieve IBM Cloud Object Storage data. This article will walk through connecting to IBM Cloud Object Storage and creating a simple VCL application with the Form Designer.

Creating a VCL Application for IBM Cloud Object Storage Data

The following instructions show how to use the Form Designer to create a simple VCL Forms application that shows the basic FireDAC objects needed to connect to IBM Cloud Object Storage from any application.

The following example populates a TDBGrid control.

  1. Create a new VCL Forms Application.
  2. Drop a TFDPhysIBMCloudObjectStorageDriverLink and TFDConnection object onto the form.
  3. Double-click the TFDConnection object. The FireDAC Connection Editor is displayed. Select "CData.IBMCloudObjectStorage" in the DriverId menu and configure the connection properties.

    Register a New Instance of Cloud Object Storage

    If you do not already have Cloud Object Storage in your IBM Cloud account, follow the procedure below to install an instance of SQL Query in your account:

    1. Log in to your IBM Cloud account.
    2. Navigate to the page, choose a name for your instance and click Create. You will be redirected to the instance of Cloud Object Storage you just created.

    Connecting using OAuth Authentication

    There are certain connection properties you need to set before you can connect. You can obtain these as follows:

    API Key

    To connect with IBM Cloud Object Storage, you need an API Key. You can obtain this as follows:

    1. Log in to your IBM Cloud account.
    2. Navigate to the Platform API Keys page.
    3. On the middle-right corner click "Create an IBM Cloud API Key" to create a new API Key.
    4. In the pop-up window, specify the API Key name and click "Create". Note the API Key as you can never access it again from the dashboard.

    Cloud Object Storage CRN

    If you have multiple accounts, you will need to specify the CloudObjectStorageCRN explicitly. To find the appropriate value, you can:

    • Query the Services view. This will list your IBM Cloud Object Storage instances along with the CRN for each.
    • Locate the CRN directly in IBM Cloud. To do so, navigate to your IBM Cloud Dashboard. In the Resource List, Under Storage, select your Cloud Object Storage resource to get its CRN.

    Connecting to Data

    You can now set the following to connect to data:

    • InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
    • ApiKey: Set this to your API key which was noted during setup.
    • CloudObjectStorageCRN (Optional): Set this to the cloud object storage CRN you want to work with. While the connector attempts to retrieve this automatically, specifying this explicitly is recommended if you have more than Cloud Object Storage account.

    When you connect, the connector completes the OAuth process.

    1. Extracts the access token and authenticates requests.
    2. Saves OAuth values in OAuthSettingsLocation to be persisted across connections.

  4. Drop a TFDQuery object onto the form and set the properties below:

    • Connection - Set this property to the TFDConnection object, if this object is not already specified.
    • SQL - Click the button in the SQL property and enter a query.
    • Active - Set this property to true.
  5. Drop a TDataSource object onto the form and set the following property:

    • DataSet - In the menu for this property, select the name of the TFDQuery object.
  6. Drop a TDBGrid control onto the form and set the following property:

    • DataSource - Select the name of the TDataSource.
  7. Drop a TFDGUIxWaitCursor onto the form. This is required to avoid a run-time error.

You now have an executable application that displays the results of the SQL Query set in the TFDQuery object.

 
 
ダウンロード