Ready to get started?

Download a free trial of the SAP Ariba Source Driver to get started:

 Download Now

Learn more:

SAP Ariba Source Icon SAP Ariba Source JDBC Driver

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

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



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

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

    <Configure id='saparibasourcedemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="saparibasourcedemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="saparibasourcedemo"/></Arg> <Arg>jdbc/saparibasourcedb</Arg> <Arg> <New class="cdata.jdbc.saparibasource.SAPAribaSourceDriver"> <Set name="url">jdbc:saparibasource:</Set> <Set name="API">SupplierDataAPIWithPagination-V4</Set> <Set name="APIKey">wWVLn7WTAXrIRMAzZ6VnuEj7Ekot5jnU</Set> <Set name="Environment">SANDBOX</Set> <Set name="Realm">testRealm</Set> <Set name="AuthScheme">OAuthClient</Set> <Set name="InitiateOAuth">GETANDREFRESH</Set> </New> </Arg> </New> </Configure>

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

    • API: Specify which API you would like the provider to retrieve SAP Ariba data from. Select the Supplier, Sourcing Project Management, or Contract API based on your business role (possible values are SupplierDataAPIWithPaginationV4, SourcingProjectManagementAPIV2, or ContractAPIV1).
    • DataCenter: The data center where your account's data is hosted.
    • Realm: The name of the site you want to access.
    • Environment: Indicate whether you are connecting to a test or production environment (possible values are TEST or PRODUCTION).

    If you are connecting to the Supplier Data API or the Contract API, additionally set the following:

    • User: Id of the user on whose behalf API calls are invoked.
    • PasswordAdapter: The password associated with the authenticating User.

    If you're connecting to the Supplier API, set ProjectId to the Id of the sourcing project you want to retrieve data from.

    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/saparibasourcedb javax.sql.DataSource Container
  5. You can then access SAP Ariba Source with a lookup to java:comp/env/jdbc/saparibasourcedb: InitialContext ctx = new InitialContext(); DataSource mysaparibasource = (DataSource)ctx.lookup("java:comp/env/jdbc/saparibasourcedb");

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.