Connect to Claude Compliance Data from a Connection Pool in Jetty
The CData JDBC driver for Claude Compliance is easy to integrate with Java Web applications. This article shows how to efficiently connect to Claude Compliance data in Jetty by configuring the driver for connection pooling. You will configure a JNDI resource for Claude Compliance in Jetty.
Configure the JDBC Driver for Salesforce as a JNDI Data Source
Follow the steps below to connect to Salesforce from Jetty.
Enable the JNDI module for your Jetty base. The following command enables JNDI from the command-line:
java -jar ../start.jar --add-to-startd=jndi- Add the CData and license file, located in the lib subfolder of the installation directory, into the lib subfolder of the context path.
-
Declare the resource and its scope. Enter the required connection properties in the resource declaration. This example declares the Claude Compliance data source at the level of the Web app, in WEB-INF\jetty-env.xml.
<Configure id='claudecompliancedemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="claudecompliancedemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="claudecompliancedemo"/></Arg> <Arg>jdbc/claudecompliancedb</Arg> <Arg> <New class="cdata.jdbc.claudecompliance.ClaudeComplianceDriver"> <Set name="url">jdbc:claudecompliance:</Set> <Set name="APIKey">your_compliance_access_key</Set> </New> </Arg> </New> </Configure>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.
-
Configure the resource in the Web.xml:
jdbc/claudecompliancedb javax.sql.DataSource Container -
You can then access Claude Compliance with a lookup to java:comp/env/jdbc/claudecompliancedb:
InitialContext ctx = new InitialContext(); DataSource myclaudecompliance = (DataSource)ctx.lookup("java:comp/env/jdbc/claudecompliancedb");
More Jetty Integration
The steps above show how to configure the driver in a simple connection pooling scenario. For more use cases and information, see the Working with Jetty JNDI chapter in the Jetty documentation.