Ready to get started?

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

 Download Now

Learn more:

Paylocity Icon Paylocity JDBC Driver

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

Connect to Paylocity Data from a Connection Pool in Jetty



The Paylocity JDBC Driver supports connection pooling: This article shows how to connect faster to Paylocity data from Web apps in Jetty.

The CData JDBC driver for Paylocity is easy to integrate with Java Web applications. This article shows how to efficiently connect to Paylocity data in Jetty by configuring the driver for connection pooling. You will configure a JNDI resource for Paylocity in Jetty.

Configure the JDBC Driver for Salesforce as a JNDI Data Source

Follow the steps below to connect to Salesforce from Jetty.

  1. 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
  2. Add the CData and license file, located in the lib subfolder of the installation directory, into the lib subfolder of the context path.
  3. Declare the resource and its scope. Enter the required connection properties in the resource declaration. This example declares the Paylocity data source at the level of the Web app, in WEB-INF\jetty-env.xml.

    <Configure id='paylocitydemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="paylocitydemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="paylocitydemo"/></Arg> <Arg>jdbc/paylocitydb</Arg> <Arg> <New class="cdata.jdbc.paylocity.PaylocityDriver"> <Set name="url">jdbc:paylocity:</Set> <Set name="OAuthClientID">YourClientId</Set> <Set name="OAuthClientSecret">YourClientSecret</Set> <Set name="RSAPublicKey">YourRSAPubKey</Set> <Set name="Key">YourKey</Set> <Set name="IV">YourIV</Set> <Set name="InitiateOAuth">GETANDREFRESH</Set> </New> </Arg> </New> </Configure>

    Set the following to establish a connection to Paylocity:

    • RSAPublicKey: Set this to the RSA Key associated with your Paylocity, if the RSA Encryption is enabled in the Paylocity account.

      This property is required for executing Insert and Update statements, and it is not required if the feature is disabled.

    • UseSandbox: Set to true if you are using sandbox account.
    • CustomFieldsCategory: Set this to the Customfields category. This is required when IncludeCustomFields is set to true. The default value for this property is PayrollAndHR.
    • Key: The AES symmetric key(base 64 encoded) encrypted with the Paylocity Public Key. It is the key used to encrypt the content.

      Paylocity will decrypt the AES key using RSA decryption.
      It is an optional property if the IV value not provided, The driver will generate a key internally.

    • IV: The AES IV (base 64 encoded) used when encrypting the content. It is an optional property if the Key value not provided, The driver will generate an IV internally.

    Connect Using OAuth Authentication

    You must use OAuth to authenticate with Paylocity. OAuth requires the authenticating user to interact with Paylocity using the browser. For more information, refer to the OAuth section in the Help documentation.

    The Pay Entry API

    The Pay Entry API is completely separate from the rest of the Paylocity API. It uses a separate Client ID and Secret, and must be explicitly requested from Paylocity for access to be granted for an account. The Pay Entry API allows you to automatically submit payroll information for individual employees, and little else. Due to the extremely limited nature of what is offered by the Pay Entry API, we have elected not to give it a separate schema, but it may be enabled via the UsePayEntryAPI connection property.

    Please be aware that when setting UsePayEntryAPI to true, you may only use the CreatePayEntryImportBatch & MergePayEntryImportBatchgtable stored procedures, the InputTimeEntry table, and the OAuth stored procedures. Attempts to use other features of the product will result in an error. You must also store your OAuthAccessToken separately, which often means setting a different OAuthSettingsLocation when using this connection property.

  4. Configure the resource in the Web.xml:

    jdbc/paylocitydb javax.sql.DataSource Container
  5. You can then access Paylocity with a lookup to java:comp/env/jdbc/paylocitydb: InitialContext ctx = new InitialContext(); DataSource mypaylocity = (DataSource)ctx.lookup("java:comp/env/jdbc/paylocitydb");

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.