Connect to Claude Compliance Data in JRuby
JRuby is a high-performance, stable, fully threaded Java implementation of the Ruby programming language. The CData JDBC Driver for Claude Compliance makes it easy to integrate connectivity to live Claude Compliance data in JRuby. This article shows how to create a simple JRuby app that connects to Claude Compliance data, executes a query, and displays the results.
Configure a JDBC Connection to Claude Compliance Data
Before creating the app, note the installation location for the JAR file for the JDBC Driver (typically C:\Program Files\CData\CData JDBC Driver for Claude Compliance\lib).
JRuby natively supports JDBC, so you can easily connect to Claude Compliance and execute SQL queries. Initialize the JDBC connection with the getConnection function of the java.sql.DriverManager class.
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
- Enable the Compliance API for your organization.
- Sign in to claude.ai as a primary owner or organization owner and open Organization settings > API > Keys.
- 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.
- 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.
Below is a typical JDBC connection string for Claude Compliance:
jdbc:claudecompliance:APIKey=your_compliance_access_key;
Create a JRuby App with Connectivity to Claude Compliance Data
Create a new Ruby file (for example: ClaudeComplianceSelect.rb) and open it in a text editor. Copy the following code into your file:
require 'java'
require 'rubygems'
require 'C:/Program Files/CData/CData JDBC Driver for Claude Compliance 2018/lib/cdata.jdbc.claudecompliance.jar'
url = "jdbc:claudecompliance:APIKey=your_compliance_access_key;"
conn = java.sql.DriverManager.getConnection(url)
stmt = conn.createStatement
rs = stmt.executeQuery("SELECT Id, Name FROM Projects")
while (rs.next) do
puts rs.getString(1) + ' ' + rs.getString(2)
end
With the file completed, you are ready to display your Claude Compliance data with JRuby. To do so, simply run your file from the command line:
jruby -S ClaudeComplianceSelect.rb
Writing SQL-92 queries to Claude Compliance allows you to quickly and easily incorporate Claude Compliance data into your own JRuby applications. Download a free trial today!