Ready to get started?

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

Download Now

A PostgreSQL Interface for UPS Data

Use the Remoting features of the UPS JDBC Driver to create a PostgreSQL entry-point for data access.

There are a vast number of PostgreSQL clients available on the Internet. From standard Drivers to BI and Analytics tools, PostgreSQL is a popular interface for data access. Using our JDBC Drivers, you can now create PostgreSQL entry-points that you can connect to from any standard client.

To access UPS data as a PostgreSQL database, use the CData JDBC Driver for UPS and a JDBC foreign data wrapper (FDW). In this article, we compile the FDW, install it, and query UPS data from PostgreSQL Server.

Connect to UPS Data as a JDBC Data Source

To connect to UPS as a JDBC data source, you will need the following:

  • Driver JAR path: The JAR is located in the lib subfolder of the installation directory.
  • Driver class: cdata.jdbc.ups.UPSDriver

  • JDBC URL: The URL must start with "jdbc:ups:" and can include any of the connection properties in name-value pairs separated with semicolons.

    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.

    A typical JDBC URL is below:

    jdbc:ups:Server=https://wwwcie.ups.com/ups.app/xml;AccessKey=myAccessKey;Password=myPassword;AccountNumber=myAccountNumber;UserId=myUserIdInitiateOAuth=GETANDREFRESH

Build the JDBC Foreign Data Wrapper

The Foreign Data Wrapper can be installed as an extension to PostgreSQL, without recompiling PostgreSQL. The jdbc2_fdw extension is used as an example.

  1. Add a symlink from the shared object for your version of the JRE to /usr/lib/libjvm.so. For example: ln -s /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/libjvm.so /usr/lib/libjvm.so
  2. Start the build: make install USE_PGXS=1

Query UPS Data as a PostgreSQL Database

After you have installed the extension, follow the steps below to start executing queries to UPS data:

  1. Log into your database.
  2. Load the extension for the database: CREATE EXTENSION jdbc2_fdw;
  3. Create a server object for UPS: CREATE SERVER UPS FOREIGN DATA WRAPPER jdbc2_fdw OPTIONS ( drivername 'cdata.jdbc.ups.UPSDriver', url 'jdbc:ups:Server=https://wwwcie.ups.com/ups.app/xml;AccessKey=myAccessKey;Password=myPassword;AccountNumber=myAccountNumber;UserId=myUserIdInitiateOAuth=GETANDREFRESH', querytimeout '15', jarfile '/home/MyUser/CData/CData\ JDBC\ Driver\ for\ Salesforce MyDriverEdition/lib/cdata.jdbc.ups.jar');
  4. Create a user mapping for the username and password of a user known to the MySQL daemon. CREATE USER MAPPING for postgres SERVER UPS OPTIONS ( username 'admin', password 'test');
  5. Create a foreign table in your local database: postgres=# CREATE FOREIGN TABLE senders ( senders_id text, senders_FirstName text, senders_Phone numeric) SERVER UPS OPTIONS ( table_name 'senders');
You can now execute read/write commands to UPS: postgres=# SELECT * FROM senders;