Connect to UKG Pro HCM Data from a Connection Pool in Jetty
The CData JDBC driver for UKG Pro HCM is easy to integrate with Java Web applications. This article shows how to efficiently connect to UKG Pro HCM data in Jetty by configuring the driver for connection pooling. You will configure a JNDI resource for UKG Pro HCM 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 UKG Pro HCM data source at the level of the Web app, in WEB-INF\jetty-env.xml.
<Configure id='ukgprohcmdemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="ukgprohcmdemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="ukgprohcmdemo"/></Arg> <Arg>jdbc/ukgprohcmdb</Arg> <Arg> <New class="cdata.jdbc.api.APIDriver"> <Set name="url">jdbc:api:</Set> <Set name="Profile">C:\profiles\UKGProHCM.apip</Set> <Set name="AuthScheme">Basic</Set> <Set name="User">your_username</Set> <Set name="Password">your_password</Set> <Set name="ProfileSettings">'Host</Set> <Set name="CustomerAPIKey">your_customer_api_key'</Set> </New> </Arg> </New> </Configure>Start by setting the Profile connection property to the location of the UKGProHCM Profile on disk (e.g. C:\profiles\UKGProHCM.apip). Next, set the ProfileSettings connection property to the connection string for UKGProHCM (see below).
UKGProHCM API Profile Settings
UKG Pro HCM uses Basic authentication combined with a customer API key to authorize access to the API. To connect, you will need your UKG Pro HCM credentials and a customer API key issued by UKG.
Set the following connection properties to authenticate:
- AuthScheme: Set this to Basic.
- User: Set this to your UKG Pro HCM username.
- Password: Set this to your UKG Pro HCM password.
- ProfileSettings: Set this to a semicolon-separated list containing:
- Host: Your UKG Pro HCM tenant hostname (e.g., yourcompany.ultipro.com).
- CustomerAPIKey: Your UKG customer API key. This is passed as the US-CUSTOMER-API-KEY request header on each API call.
To obtain your customer API key, contact your UKG Pro HCM administrator or refer to the UKG Developer Portal at https://developer.ukg.com.
-
Configure the resource in the Web.xml:
jdbc/ukgprohcmdb javax.sql.DataSource Container -
You can then access UKG Pro HCM with a lookup to java:comp/env/jdbc/ukgprohcmdb:
InitialContext ctx = new InitialContext(); DataSource myukgprohcm = (DataSource)ctx.lookup("java:comp/env/jdbc/ukgprohcmdb");
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.