Ready to get started?

Download a free trial of the Workday Driver to get started:

 Download Now

Learn more:

Workday Icon Workday JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Workday.

Create a Data Access Object for Workday Data using JDBI



A brief overview of creating a SQL Object API for Workday 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 Workday integrates connectivity to live Workday data in Java applications. By pairing these technologies, you gain simple, programmatic access to Workday data. This article walks through building a basic Data Access Object (DAO) and the accompanying code to read Workday data.

Create a DAO for the Workday Workers 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 MyWorkersDAO { //request specific data from Workday (String type is used for simplicity) @SqlQuery("SELECT Legal_Name_Last_Name FROM Workers WHERE Legal_Name_Last_Name = :legal_Name_Last_Name") String findLegal_Name_Last_NameByLegal_Name_Last_Name(@Bind("legal_Name_Last_Name") String legal_Name_Last_Name); /* * close with no args is used to close the connection */ void close(); }

Open a Connection to Workday

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

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.

A connection string for Workday will typically look like the following:

jdbc:workday:User=myuser;Password=mypassword;Tenant=mycompany_gm1;Host=https://wd3-impl-services1.workday.com

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:workday:User=myuser;Password=mypassword;Tenant=mycompany_gm1;Host=https://wd3-impl-services1.workday.com"); MyWorkersDAO dao = dbi.open(MyWorkersDAO.class); //do stuff with the DAO dao.close();

Read Workday Data

With the connection open to Workday, simply call the previously defined method to retrieve data from the Workers entity in Workday.

//disply the result of our 'find' method String legal_Name_Last_Name = dao.findLegal_Name_Last_NameByLegal_Name_Last_Name("Morgan"); System.out.println(legal_Name_Last_Name);

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