Discover how a bimodal integration strategy can address the major data management challenges facing your organization today.
Get the Report →Connect to Workday Data in JRuby
Create a simple JRuby app with access to live Workday data.
JRuby is a high-performance, stable, fully threaded Java implementation of the Ruby programming language. The CData JDBC Driver for Workday makes it easy to integrate connectivity to live Workday data in JRuby. This article shows how to create a simple JRuby app that connects to Workday data, executes a query, and displays the results.
Configure a JDBC Connection to Workday 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 Workday\lib).
JRuby natively supports JDBC, so you can easily connect to Workday and execute SQL queries. Initialize the JDBC connection with the getConnection function of the java.sql.DriverManager class.
To connect, there are three pieces of information required: Authentication, API URL, and WSDL URL.
Authentication
To authenticate, specify your User and Password. Note that you must append your Tenant to your User separated by an '@' character. For instance, if you normally log in with 'geraldg' and your Tenant is 'mycompany_mc1', then your User should be specified as 'geraldg@mycompany_mc1'.
API URL
The API URL may be specified either directly via APIURL, or it may be constructed from the Tenant, Service, and Host. The APIURL is constructed in the following format: <Host>/ccx/service/<Tenant>/<Service>.
WSDL URL
The WSDLURL may be specified in its entirety, or may be constructed from the Service and WSDLVersion connection properties. The WSDLURL is constructed in the following format: https://community.workday.com/sites/default/files/file-hosting/productionapi/<Service>/<WSDLVersion>/<Service>.wsdl
Built-in Connection String Designer
For assistance in constructing the JDBC URL, use the connection string designer built into the Workday JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.
java -jar cdata.jdbc.workday.jar
Fill in the connection properties and copy the connection string to the clipboard.
Below is a typical JDBC connection string for Workday:
jdbc:workday:User=myuser;Password=mypassword;Tenant=mycompany_gm1;Host=https://wd3-impl-services1.workday.com
Create a JRuby App with Connectivity to Workday Data
Create a new Ruby file (for example: WorkdaySelect.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 Workday 2018/lib/cdata.jdbc.workday.jar'
url = "jdbc:workday:User=myuser;Password=mypassword;Tenant=mycompany_gm1;Host=https://wd3-impl-services1.workday.com"
conn = java.sql.DriverManager.getConnection(url)
stmt = conn.createStatement
rs = stmt.executeQuery("SELECT Worker_Reference_WID, Legal_Name_Last_Name FROM Workers")
while (rs.next) do
puts rs.getString(1) + ' ' + rs.getString(2)
end
With the file completed, you are ready to display your Workday data with JRuby. To do so, simply run your file from the command line:
jruby -S WorkdaySelect.rb
Writing SQL-92 queries to Workday allows you to quickly and easily incorporate Workday data into your own JRuby applications. Download a free trial today!