JDBC Driver for IBM Cloud Object Storage

Build 22.0.8462

Establishing a Connection

Creating a JDBC Data Source

You can create a JDBC data source to connect from your Java application. Creating a JDBC data source based on the CData JDBC Driver for IBM Cloud Object Storage consists of three basic steps:

  • Add the driver JAR file to the classpath. The JAR file is located in the lib subfolder of the installation directory. Note that the .lic file must be located in the same folder as the JAR file.
  • Provide the driver class. For example:
    cdata.jdbc.ibmcloudobjectstorage.IBMCloudObjectStorageDriver
  • Provide the JDBC URL. For example:
    jdbc:ibmcloudobjectstorage:ApiKey=myApiKey;CloudObjectStorageCRN=MyInstanceCRN;Region=myRegion;OAuthClientId=MyOAuthClientId;OAuthClientSecret=myOAuthClientSecret;
    
    or
    
    jdbc:cdata:ibmcloudobjectstorage:ApiKey=myApiKey;CloudObjectStorageCRN=MyInstanceCRN;Region=myRegion;OAuthClientId=MyOAuthClientId;OAuthClientSecret=myOAuthClientSecret;

    The second format above can be used whenever there is a conflict in your application between drivers using the same URL format to ensure you are using the CData driver. The URL must start with either "jdbc:ibmcloudobjectstorage:" or "jdbc:cdata:ibmcloudobjectstorage:" and can include any of the connection properties in name-value pairs separated with semicolons.

Before You Connect

Before you can connect to IBM Cloud Object Storage, you need to register a IBM Cloud Object Storage instance, then find and note your IBM Cloud Object Storage API Key and CRN.

Register a New Instance of Cloud Object Storage

If you do not already have Cloud Object Storage in your IBM Cloud account, you can 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 Cloud Object Storage page, choose a name for your instance and click Create. You will be redirected to the instance of Cloud Object Storage you just created.

API Key

You can obtain your ApiKey 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

By default, the driver will attempt to automatically determine a Cloud Object Storage CRN. However, if you have multiple accounts, you will need to specify the CloudObjectStorageCRN explicitly. You can obtain this value in one of two ways:

  • 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 IBM Cloud Object Storage

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 your noted cloud object storage CRN. While the driver attempts to retrieve this automatically, specifying this explicitly is recommended if you have more than one Cloud Object Storage account.

When you connect, the driver completes the OAuth process.

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

Copyright (c) 2023 CData Software, Inc. - All rights reserved.
Build 22.0.8462