Integrate with Live Lakebase Data in MuleSoft (via CData Connect AI)

Dibyendu Datta
Dibyendu Datta
Lead Technology Evangelist
Use CData Connect AI to connect to Lakebase from the MuleSoft Anypoint Platform to integrate live Lakebase data into custom reports and dashboards.

The MuleSoft Anypoint Platform enables the building, deployment, and management of APIs and integrations, facilitating seamless connectivity across applications and systems. When combined with CData Connect AI, it provides access to Lakebase data for visualizations, dashboards, and more. This article explains how to use CData Connect AI to create a live connection to Lakebase and how to connect and access live Lakebase data from the MuleSoft Anypoint Platform.

Prerequisites

Before configuring and using MuleSoft with CData Connect AI, you must first connect a data source to your CData Connect AI account. For more information, see the Connections section.

Additionally, you need to generate a Personal Access Token (PAT) on the Settings page. Be sure to copy it down, as it serves as your password during authentication.

Configure Lakebase Connectivity for MuleSoft

Connectivity to Lakebase from MuleSoft is made possible through CData Connect AI. To work with Lakebase data from MuleSoft, we start by creating and configuring a Lakebase connection.

  1. Log into Connect AI, click Sources, and then click Add Connection
  2. Select "Lakebase" from the Add Connection panel
  3. Enter the necessary authentication properties to connect to Lakebase. To connect to Databricks Lakebase, start by setting the following properties:
    • DatabricksInstance: The Databricks instance or server hostname, provided in the format instance-abcdef12-3456-7890-abcd-abcdef123456.database.cloud.databricks.com.
    • Server: The host name or IP address of the server hosting the Lakebase database.
    • Port (optional): The port of the server hosting the Lakebase database, set to 5432 by default.
    • Database (optional): The database to connect to after authenticating to the Lakebase Server, set to the authenticating user's default database by default.

    OAuth Client Authentication

    To authenicate using OAuth client credentials, you need to configure an OAuth client in your service principal. In short, you need to do the following:

    1. Create and configure a new service principal
    2. Assign permissions to the service principal
    3. Create an OAuth secret for the service principal

    For more information, refer to the Setting Up OAuthClient Authentication section in the Help documentation.

    OAuth PKCE Authentication

    To authenticate using the OAuth code type with PKCE (Proof Key for Code Exchange), set the following properties:

    • AuthScheme: OAuthPKCE.
    • User: The authenticating user's user ID.

    For more information, refer to the Help documentation.

  4. Click Save & Test
  5. Navigate to the Permissions tab in the Add Lakebase Connection page and update the User-based permissions.

Add a Personal Access Token

When connecting to Connect AI through the REST API, the OData API, or the Virtual SQL Server, a Personal Access Token (PAT) is used to authenticate the connection to Connect AI. It is best practice to create a separate PAT for each service to maintain granularity of access.

  1. Click on the Gear icon () at the top right of the Connect AI app to open the settings page.
  2. On the Settings page, go to the Access Tokens section and click Create PAT.
  3. Give the PAT a name and click Create.
  4. The personal access token is only visible at creation, so be sure to copy it and store it securely for future use.

With the connection configured and a PAT generated, you are ready to connect to Lakebase data from Mulesoft.

Connecting to CData Connect AI

Follow these steps to establish a connection from Mulesoft to CData Connect AI through the JDBC driver:

  1. Download and install the CData Connect AI JDBC driver.
    • Open the Integrations page of CData Connect AI.
    • Search for and select JDBC.
    • Download and run the setup file.
    • When the installation is complete, the JAR file can be found in the installation directory (inside the lib folder).
  2. Log into Mulesoft Anypoint Studio or launch the desktop application.
  3. Create a new Mulesoft project. The new project appears in a project folder.
  4. In the Mule Palette located on the right, drag an HTTP Listener to the Message Flow area.
  5. Click on the HTTP Listener to configure it.
  6. Click the + sign on the right of Connector configuration. The HTTP Listener config dialog appears.
  7. Configure the HTTP Listener, providing a Port on which to query your data, and click OK.
  8. Provide a path on which to perform the actions. The HTTP Listener is now configured.
  9. In the Mule Palette on the right, type database in the search bar.
  10. Drag the database operation you want to perform to the Message Flow area. For this example, we choose Select.
  11. Select Generic Connection from the Connection dropdown in the Database Config dialog.
  12. Click the Configure button to configure the JDBC driver. Select Use local file from the drop-down list.
  13. Locate the CData Connect AI JAR file from the JDBC driver installation and click OK.
  14. Provide the following information:
    • URL: the URL for the connection, for example:
       jdbc:connect:Authscheme=Basic;user=username;password=PAT
      Note: the password is the PAT created in the Prerequisites section.
    • Driver class name: Enter the Driver class name as:
       cdata.jdbc.connect.ConnectDriver
  15. Click Test Connection.
  16. If the connection is successful, provide the SQL Query Text in the editor. You can see the table metadata on the right side in the Output tab.
  17. In the Mule Palette, drag Transform Message to the Message Flow area.
  18. Click Transform Message to configure it. Change the Output as follows:
  19. Save your project and run it. In the console, Mulesoft starts initializing the dependencies.
  20. Once you see the message, "Message source 'listener' on flow your_project_name successfully started", you can start querying your data at the endpoint you provided.
  21. Query to check out the data using the Postman application (as shown below).

SQL Access to Lakebase Data from Cloud Applications

Now you have a direct connection to live Lakebase data from MuleSoft Anypoint Platform. You can create more connections to ensure seamless data flow, automate business processes, and manage APIs - all without replicating Lakebase data.

To get real-time data access to 300+ SaaS, Big Data, and NoSQL sources (including Lakebase) directly from your cloud applications, explore the CData Connect AI.

Ready to get started?

Learn more about CData Connect AI or sign up for free trial access:

Free Trial