Connect to SAP Ariba Procurement Data from a Connection Pool in Jetty



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

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

    <Configure id='saparibaprocurementdemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="saparibaprocurementdemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="saparibaprocurementdemo"/></Arg> <Arg>jdbc/saparibaprocurementdb</Arg> <Arg> <New class="cdata.jdbc.saparibaprocurement.SAPAribaProcurementDriver"> <Set name="url">jdbc:saparibaprocurement:</Set> <Set name="ANID">AN02000000280</Set> <Set name="API">PurchaseOrdersBuyerAPI-V1</Set> <Set name="APIKey">wWVLn7WTAXrIRMAzZ6VnuEj7Ekot5jnU</Set> <Set name="AuthScheme">OAuthClient</Set> <Set name="InitiateOAuth">GETANDREFRESH</Set> </New> </Arg> </New> </Configure>

    In order to connect with SAP Ariba Procurement, set the following:

    • ANID: Your Ariba Network ID.
    • ANID: Specify which API you would like the provider to retrieve SAP Ariba data from. Select the Buyer or Supplier API based on your business role (possible values are PurchaseOrdersBuyerAPIV1 or PurchaseOrdersSupplierAPIV1).
    • Environment: Indicate whether you are connecting to a test or production environment (possible values are TEST or PRODUCTION).

    Authenticating with OAuth

    After setting connection properties, you need to configure OAuth connectivity to authenticate.

    • Set AuthScheme to OAuthClient.
    • Register an application with the service to obtain the APIKey, OAuthClientId and OAuthClientSecret.

      For more information on creating an OAuth application, refer to the Help documentation.

    Automatic OAuth

    After setting the following, you are ready to connect:

      APIKey: The Application key in your app settings. OAuthClientId: The OAuth Client Id in your app settings. OAuthClientSecret: The OAuth Secret in your app settings.

    When you connect, the provider automatically completes the OAuth process:

    1. The provider obtains an access token from SAP Ariba and uses it to request data.
    2. The provider refreshes the access token automatically when it expires.
    3. The OAuth values are saved in memory relative to the location specified in OAuthSettingsLocation.
  4. Configure the resource in the Web.xml:

    jdbc/saparibaprocurementdb javax.sql.DataSource Container
  5. You can then access SAP Ariba Procurement with a lookup to java:comp/env/jdbc/saparibaprocurementdb: InitialContext ctx = new InitialContext(); DataSource mysaparibaprocurement = (DataSource)ctx.lookup("java:comp/env/jdbc/saparibaprocurementdb");

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 SAP Ariba Procurement Driver to get started:

 Download Now

Learn more:

SAP Ariba Procurement Icon SAP Ariba Procurement JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with SAP Ariba Procurement.