Compile an application against your COD database

Once you have created your application and a database using Cloudera Operational Database (COD), you have to compile your application against your database.

  • Set your CDP workload password. For more information, see the Setting the IPA Password documentation.
  • Grant the ODUser role to the machine user using the Management Console Actions > Manage Acces page for their CDP environment. By setting the ODUser role you can grant a number of rights in the system that allows you to access the COD using the machine user's workload password.
  • Add synchronized users from User Management Service in the CDP Control Plane into the environment in which your COD database is running.
  1. Configure Maven to use your CDP password.
    1. Generate a master password and store it in ~/.m2/settings-security.xml:
      $ mvn --encrypt-master-password
      Password: <your hard-to-guess secret key>
      The settings-security.xml file looks like:
      <settingsSecurity>
        <master>{your_encoded_master_password}</master>
      </settingsSecurity>
      
    2. Encrypt your CDP password using the master password:
      $ mvn --encrypt-password
      Password: <cdp-workload-password>
      
    3. Create a servers element in your ~/.m2/settings.xml file, that stores your CDP username and encrypted workload password:
      <settings ...>
        <servers>
          <server>
            <id>nosql-cod</id>
            <username>username</username>
            <password>{encrypted_workload_password}</password>
          </server>
        </servers>
      </settings>
      
  2. Get the Maven repository location to fetch JAR files.
    There are two ways to get the necessary information:
    • In command line: Using the cdp opdb describe-client-connectivity --database-name <your_database> --environment-name <your_environment> command.
    • In the COD user interface: Clicking the Connect bar and selecting the applicable client.

    You have to use the version and the mavenURL attributes in your Maven project and configuration.

    The following is an example about how to fetch the required HBase information to build your application:
    $ cdp opdb describe-client-connectivity --database-name <your_database> --environment-name <your_environment>  | jq '.connectors[] | select(.name == "hbase")'
    {
      "name": "hbase",
      "version": "2.2.3.7.2.0.0-219",
      "kind": "LIBRARY",
      "dependencies": {
        "mavenUrl": "<https://maven_URL/cdp-proxy/hbase/jars>"
      },
      "configuration": {
        "clientConfigurationUrl": "<http://client_Configuration_URL/.../services/hbase/clientConfig>"
      },
      "requiresKerberos": true
    
    The following example fetch the required Phoenix information to build your application:
     cdp opdb describe-client-connectivity --database-name <your_database> --environment-name <your_environment> | jq ".connectors[] | select(.name == \"phoenix-thick-jdbc\") | .dependencies.mavenUrl"
      cdp opdb describe-client-connectivity --database-name <your_database> --environment-name <your_environment> | jq ".connectors[] | select(.name == \"phoenix-thin-jdbc\") | .version"
    
    Phoenix-thick
    "https://maven_URL/cdp-proxy-api/avatica/maven"
    "5.0.0.7.2.0.0-128"
    Phoenix-thin
    "https://maven_URL/cdp-proxy-api/avatica/maven"
    "5.0.0.7.2.0.0-128"
    
  3. Modify your application's settings.
    Ensure your application's settings.xml file uses the correct URL and version for your COD database.
    An example when using NoSQL client:
    <project>
      <dependencies>
        <!-- NoSQL client for COD -->
        <dependency>
          <groupId>org.apache.hbase</groupId>
          <artifactId>hbase-shaded-client</artifactId>
          <version>2.2.3.7.2.0.0-219</version>
        </dependency>
      </dependencies>
      ...
      <repositories>
        <!-- Define our COD repository; this would be given to us by COD itself -->
        <repository>
          <id>nosql-odx</id>
    <url>https://maven_URL/cdp-proxy/hbase/jars</url>
          <name>Cloudera NoSQL COD Repository</name>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
      </repositories>
    </project>
    
    An example when using SQL client:
    <project>
      <dependencies>
        <!-- SQL client for ODX -->
        <dependency>
          <groupId>org.apache.phoenix</groupId>
          <artifactId>phoenix-client</artifactId>
          <version>5.0.0.7.2.0.0-128</version>
        </dependency>
        <dependency>
          <groupId>org.apache.phoenix</groupId>
          <artifactId>phoenix-queryserver-client</artifactId>
          <version>5.0.0.7.2.0.0-128</version>
        </dependency>
      </dependencies>
      ...
      <repositories>
        <!-- Define our COD repository -->
        <repository>
          <id>sql-cod</id>
    <url>https://maven_URL/cdp-proxy-api/avatica/maven</url>
          <name>Cloudera SQL COD Repository</name>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
      </repositories>
    </project>
    
  4. Build your application.
  5. Run your application for the applicable client.