Connect to Adobe Experience Manager Data in JRuby

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Create a simple JRuby app with access to live Adobe Experience Manager data.

JRuby is a high-performance, stable, fully threaded Java implementation of the Ruby programming language. The CData JDBC Driver for Adobe Experience Manager makes it easy to integrate connectivity to live Adobe Experience Manager data in JRuby. This article shows how to create a simple JRuby app that connects to Adobe Experience Manager data, executes a query, and displays the results.

Configure a JDBC Connection to Adobe Experience Manager 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 Adobe Experience Manager\lib).

JRuby natively supports JDBC, so you can easily connect to Adobe Experience Manager and execute SQL queries. Initialize the JDBC connection with the getConnection function of the java.sql.DriverManager class.

The driver connects to Adobe Experience Manager (AEM) instances that expose the JCR repository over WebDAV. It supports both on-premises AEM and AEM as a Cloud Service deployments.

To establish a connection, set the following properties:

  • URL: The WebDAV-enabled JCR server URL.
    • AEM as a Cloud Service: https://author-pXXXXX-eXXXXX.adobeaemcloud.com/crx/server
    • Local development: http://localhost:4502/crx/server
  • User: Your AEM username.
  • Password: Your AEM password.

Note: Tables are dynamically generated based on the JCR repository structure. Ensure that the configured user has sufficient permissions to access the required content paths in the AEM repository.

Built-in Connection String Designer

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

java -jar cdata.jdbc.adobeexperiencemanager.jar

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

Below is a typical JDBC connection string for Adobe Experience Manager:

jdbc:adobeexperiencemanager:URL=https://author-p12345-e67890.adobeaemcloud.com/crx/server;User=admin;Password=admin;

Create a JRuby App with Connectivity to Adobe Experience Manager Data

Create a new Ruby file (for example: AdobeExperienceManagerSelect.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 Adobe Experience Manager 2018/lib/cdata.jdbc.adobeexperiencemanager.jar'

url = "jdbc:adobeexperiencemanager:URL=https://author-p12345-e67890.adobeaemcloud.com/crx/server;User=admin;Password=admin;"
conn = java.sql.DriverManager.getConnection(url)
stmt = conn.createStatement
rs = stmt.executeQuery("SELECT Id, Name FROM Content")
while (rs.next) do
  puts rs.getString(1) + ' ' + rs.getString(2)
end

With the file completed, you are ready to display your Adobe Experience Manager data with JRuby. To do so, simply run your file from the command line:

jruby -S AdobeExperienceManagerSelect.rb

Writing SQL-92 queries to Adobe Experience Manager allows you to quickly and easily incorporate Adobe Experience Manager data into your own JRuby applications. Download a free trial today!

Ready to get started?

Download a free trial of the Adobe Experience Manager Driver to get started:

 Download Now

Learn more:

Adobe Experience Manager Icon Adobe Experience Manager JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Adobe Experience Manager.