Ready to get started?

Download a free trial of the Sage 300 Driver to get started:

 Download Now

Learn more:

Sage 300 Icon Sage 300 JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Sage 300.

A PostgreSQL Interface for Sage 300 Data



Use the Remoting features of the Sage 300 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 Sage 300 data as a PostgreSQL database, use the CData JDBC Driver for Sage 300 and a JDBC foreign data wrapper (FDW). In this article, we compile the FDW, install it, and query Sage 300 data from PostgreSQL Server.

Connect to Sage 300 Data as a JDBC Data Source

To connect to Sage 300 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.sage300.Sage300Driver

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

    Sage 300 requires some initial setup in order to communicate over the Sage 300 Web API.

    • Set up the security groups for the Sage 300 user. Give the Sage 300 user access to the option under Security Groups (per each module required).
    • Edit both web.config files in the /Online/Web and /Online/WebApi folders; change the key AllowWebApiAccessForAdmin to true. Restart the webAPI app-pool for the settings to take.
    • Once the user access is configured, click https://server/Sage300WebApi/ to ensure access to the web API.

    Authenticate to Sage 300 using Basic authentication.

    Connect Using Basic Authentication

    You must provide values for the following properties to successfully authenticate to Sage 300. Note that the provider reuses the session opened by Sage 300 using cookies. This means that your credentials are used only on the first request to open the session. After that, cookies returned from Sage 300 are used for authentication.

    • Url: Set this to the url of the server hosting Sage 300. Construct a URL for the Sage 300 Web API as follows: {protocol}://{host-application-path}/v{version}/{tenant}/ For example, http://localhost/Sage300WebApi/v1.0/-/.
    • User: Set this to the username of your account.
    • Password: Set this to the password of your account.

    Built-in Connection String Designer

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

    java -jar cdata.jdbc.sage300.jar

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

    A typical JDBC URL is below:

    jdbc:sage300:User=SAMPLE;Password=password;URL=http://127.0.0.1/Sage300WebApi/v1/-/;Company=SAMINC;

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 (downloadable here).

  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 Sage 300 Data as a PostgreSQL Database

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

  1. Log into your database.
  2. Load the extension for the database: CREATE EXTENSION jdbc2_fdw;
  3. Create a server object for Sage 300: CREATE SERVER Sage300 FOREIGN DATA WRAPPER jdbc2_fdw OPTIONS ( drivername 'cdata.jdbc.sage300.Sage300Driver', url 'jdbc:sage300:User=SAMPLE;Password=password;URL=http://127.0.0.1/Sage300WebApi/v1/-/;Company=SAMINC;', querytimeout '15', jarfile '/home/MyUser/CData/CData\ JDBC\ Driver\ for\ Salesforce MyDriverEdition/lib/cdata.jdbc.sage300.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 Sage300 OPTIONS ( username 'admin', password 'test');
  5. Create a foreign table in your local database: postgres=# CREATE FOREIGN TABLE oeinvoices ( oeinvoices_id text, oeinvoices_InvoiceUniquifier text, oeinvoices_ApprovedLimit numeric) SERVER Sage300 OPTIONS ( table_name 'oeinvoices');
You can now execute SELECT commands to Sage 300: postgres=# SELECT * FROM oeinvoices;