Ready to get started?

Learn more about the CData JDBC Driver for UPS or download a free trial:

Download Now

Configure the CData JDBC Driver for UPS in a Connection Pool in Tomcat

Connect to UPS data from a connection pool in Tomcat.

The CData JDBC Drivers support standard JDBC interfaces to integrate with Web applications running on the JVM. This article details how to connect to UPS data from a connection pool in Tomcat.

Connect to UPS Data through a Connection Pool in Tomcat

  1. Copy the CData JAR and CData .lic file to $CATALINA_HOME/lib. The CData JAR is located in the lib subfolder of the installation directory.
  2. Add a definition of the resource to the context. Specify the JDBC URL here.

    The driver uses five pieces of information in order to authenticate its actions with the UPS service.

    • Server: This controls the URL where the requests should be sent. Common testing options for this are: https://wwwcie.ups.com/ups.app/xml and https://wwwcie.ups.com/webservices
    • AccessKey: This is an identifier that is required to connect to a UPS Server. This value will be provided to you by UPS after registration.
    • UserId: This value is used for logging into UPS. This value is the one you chose to login with when registering for service with UPS.
    • Password: This value is used for logging into UPS. This value is the one you chose to login with when registering for service with UPS.
    • AccountNumber: This is a valid 6-digit or 10-digit UPS account number.
    • 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.

    Built-in Connection String Designer

    For assistance in constructing the JDBC URL, use the connection string designer built into the UPS JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.

    java -jar cdata.jdbc.ups.jar

    Fill in the connection properties and copy the connection string to the clipboard.

    You can see the JDBC URL specified in the resource definition below.

    <Resource name="jdbc/ups" auth="Container" type="javax.sql.DataSource" driverClassName="cdata.jdbc.ups.UPSDriver" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" url="jdbc:ups:Server=https://wwwcie.ups.com/ups.app/xml;AccessKey=myAccessKey;Password=myPassword;AccountNumber=myAccountNumber;UserId=myUserIdInitiateOAuth=GETANDREFRESH" maxActive="20" maxIdle="10" maxWait="-1" />

    To allow a single application to access UPS data, add the code above to the context.xml in the application's META-INF directory.

    For a shared resource configuration, add the code above to the context.xml located in $CATALINA_BASE/conf. A shared resource configuration provides connectivity to UPS for all applications.

  3. Add a reference to the resource to the web.xml for the application. UPS data JSP jdbc/UPS javax.sql.DataSource Container
  4. Initialize connections from the connection pool: Context initContext = new InitialContext(); Context envContext = (Context)initContext.lookup("java:/comp/env"); DataSource ds = (DataSource)envContext.lookup("jdbc/UPS"); Connection conn = ds.getConnection();

More Tomcat Integration

The steps above show how to connect to UPS data in a simple connection pooling scenario. For more use cases and information, see the JNDI Datasource How-To in the Tomcat documentation.