Connect to Adobe Analytics Data from a Connection Pool in Jetty



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

The CData JDBC driver for Adobe Analytics is easy to integrate with Java Web applications. This article shows how to efficiently connect to Adobe Analytics data in Jetty by configuring the driver for connection pooling. You will configure a JNDI resource for Adobe Analytics 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 Adobe Analytics data source at the level of the Web app, in WEB-INF\jetty-env.xml.

    <Configure id='adobeanalyticsdemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="adobeanalyticsdemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="adobeanalyticsdemo"/></Arg> <Arg>jdbc/adobeanalyticsdb</Arg> <Arg> <New class="cdata.jdbc.adobeanalytics.AdobeAnalyticsDriver"> <Set name="url">jdbc:adobeanalytics:</Set> <Set name="GlobalCompanyId">myGlobalCompanyId</Set> <Set name="RSID">myRSID</Set> <Set name="OAuthClientId">myOauthClientId</Set> <Set name="OauthClientSecret">myOAuthClientSecret</Set> <Set name="CallbackURL">myCallbackURL</Set> </New> </Arg> </New> </Configure>

    Adobe Analytics uses the OAuth authentication standard. To authenticate using OAuth, you will need to create an app to obtain the OAuthClientId, OAuthClientSecret, and CallbackURL connection properties. See the "Getting Started" section of the help documentation for a guide.

    Retrieving GlobalCompanyId

    GlobalCompanyId is a required connection property. If you do not know your Global Company ID, you can find it in the request URL for the users/me endpoint on the Swagger UI. After logging into the Swagger UI Url, expand the users endpoint and then click the GET users/me button. Click the Try it out and Execute buttons. Note your Global Company ID shown in the Request URL immediately preceding the users/me endpoint.

    Retrieving Report Suite Id

    Report Suite ID (RSID) is also a required connection property. In the Adobe Analytics UI, navigate to Admin -> Report Suites and you will get a list of your report suites along with their identifiers next to the name.

    After setting the GlobalCompanyId, RSID and OAuth connection properties, you are ready to connect to Adobe Analytics.

  4. Configure the resource in the Web.xml:

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

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.

Ready to get started?

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

 Download Now

Learn more:

Adobe Analytics Icon Adobe Analytics JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Adobe Analytics data including Metrics, Users, Reports, Segments, and more!