Create a Data Access Object for Claude Compliance Data using JDBI

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
A brief overview of creating a SQL Object API for Claude Compliance data in JDBI.

JDBI is a SQL convenience library for Java that exposes two different style APIs, a fluent style and a SQL object style. The CData JDBC Driver for Claude Compliance integrates connectivity to live Claude Compliance data in Java applications. By pairing these technologies, you gain simple, programmatic access to Claude Compliance data. This article explains how to build a basic Data Access Object (DAO) and the accompanying code to read Claude Compliance data.

Create a DAO for the Claude Compliance Projects Entity

The interface below declares the desired behavior for the SQL object to create a single method for each SQL statement to be implemented.


public interface MyProjectsDAO {
  //request specific data from Claude Compliance (String type is used for simplicity)
  @SqlQuery("SELECT Name FROM Projects WHERE OrganizationUuid = :organizationUuid")
  String findNameByOrganizationUuid(@Bind("organizationUuid") String organizationUuid);

  /*
   * close with no args is used to close the connection
   */
  void close();
}

Open a Connection to Claude Compliance

Collect the necessary connection properties and construct the appropriate JDBC URL for connecting to Claude Compliance.

The driver connects to Claude Compliance using a Compliance Access Key, the only supported authentication method. Set the following connection property:

  • APIKey: The Compliance Access Key you created.

Creating a Compliance Access Key

  1. Enable the Compliance API for your organization.
  2. Sign in to claude.ai as a primary owner or organization owner and open Organization settings > API > Keys.
  3. Select Create Key and assign only the scopes your integration needs:
    • read:compliance_activities for Activities and the typed activity views.
    • read:compliance_org_data for organizations, roles, groups, and settings.
    • read:compliance_user_data for users, chats, files, projects, and downloads.
    • delete:compliance_user_data for the explicit Delete stored procedures.
  4. Create the key and copy it when it appears. The key starts with sk-ant-api01- and is shown only once.

Optionally, set OrganizationUUID to limit organization-scoped views (such as OrganizationUsers and ComplianceRoles) to a single linked organization. If it is left empty, those views default to the first available organization and do not include data from all linked organizations.

Built-in Connection String Designer

For assistance in constructing the JDBC URL, use the connection string designer built into the Claude Compliance JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.


java -jar cdata.jdbc.claudecompliance.jar

Fill in the connection properties and copy the connection string to the clipboard.

Using the built-in connection string designer to generate a JDBC URL (Salesforce is shown.)

A connection string for Claude Compliance will typically look like the following:

jdbc:claudecompliance:APIKey=your_compliance_access_key;

Use the configured JDBC URL to obtain an instance of the DAO interface. The particular method shown below will open a handle bound to the instance, so the instance needs to be closed explicitly to release the handle and the bound JDBC connection.


DBI dbi = new DBI("jdbc:claudecompliance:APIKey=your_compliance_access_key;");
MyProjectsDAO dao = dbi.open(MyProjectsDAO.class);

//do stuff with the DAO

dao.close();

Read Claude Compliance Data

With the connection open to Claude Compliance, simply call the previously defined method to retrieve data from the Projects entity in Claude Compliance.


//disply the result of our 'find' method
String name = dao.findNameByOrganizationUuid("abcdef01-2345-6789-abcd-ef0123456789");
System.out.println(name);

Since the JDBI library is able to work with JDBC connections, you can easily produce a SQL Object API for Claude Compliance by integrating with the CData JDBC Driver for Claude Compliance. Download a free trial and work with live Claude Compliance data in custom Java applications today.

Ready to get started?

Download a free trial of the Claude Compliance Driver to get started:

 Download Now

Learn more:

Claude Compliance Icon Claude Compliance JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Claude Compliance data including Activities, Chats, ChatMessages, CodeArtifacts, ComplianceRoles, Organizations, OrganizationUsers, Projects, and more!