Connect to FedEx Data from a Connection Pool in Jetty

Ready to get started?

Download for a free trial:

Download Now

Learn more:

FedEx JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with FedEx data including Packages, Shipments, Recipients, and more!



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

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

    <Configure id='fedexdemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="fedexdemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="fedexdemo"/></Arg> <Arg>jdbc/fedexdb</Arg> <Arg> <New class="cdata.jdbc.fedex.FedExDriver"> <Set name="url">jdbc:fedex:</Set> <Set name="Server">'https://gatewaybeta.fedex.com:443/xml'</Set> <Set name="DeveloperKey">'alsdkfjpqoewiru'</Set> <Set name="Password">'zxczxqqtyiuowkdlkn'</Set> <Set name="AccountNumber">'110371337'</Set> <Set name="MeterNumber">'240134349'</Set> <Set name="PrintLabelLocation">'C:\users\username\documents\mylabels'</Set> <Set name="CacheProvider">'org.sqlite.JDBC'</Set> <Set name="CacheConnection">'jdbc:sqlite:C:\users\username\documents\fedexcache.db'</Set> </New> </Arg> </New> </Configure>

    There are five pieces of information needed in order to authenticate its actions with the FedEx service. This information is below.

    • Server: This controls the URL where the requests should be sent. Common testing options for this are: "https://gatewaybeta.fedex.com:443/xml", "https://wsbeta.fedex.com:443/xml", "https://gatewaybeta.fedex.com:443/web-service", and "https://wsbeta.fedex.com:443/web-service"
    • DeveloperKey: This is the identifier part of the authentication key for the sender's identity. This value will be provided to you by FedEx after registration.
    • Password: This is the secret part of the authentication key for the sender's identity. This value will be provided to you by FedEx after registration.
    • AccountNumber: This valid 9-digit FedEx account number is used for logging into the FedEx server.
    • MeterNumber: This value is used for submitting requests to FedEx. This value will be provided to you by FedEx after registration.
    • PrintLabelLocation: This property is required if one intends to use the GenerateLabels or GenerateReturnLabels stored procedures. This should be set to the folder location where generated labels should be stored.

    The Cache Database

    Many of the useful tasks available from FedEx require a lot of data. To ensure this data is easy to input and recall later, utilizes a cache database to make these requests. You must set the cache connection properties:

    • CacheProvider: The specific database you are using to cache with. For example, org.sqlite.JDBC.
    • CacheConnection: The connection string to be passed to the cache provider. For example, jdbc:sqlite:C:\users\username\documents\fedexcache.db
  4. Configure the resource in the Web.xml:

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

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.