Sage USData のPostgreSQL インターフェース

Sage US JDBC Driver のRemoting 機能を使用して、データアクセス用のPostgreSQL エントリポイントを作成します。

インターネット上には利用可能な膨大な数のPostgreSQL クライアントがあります。標準のドライバーからBI および分析ツールまで、PostgreSQL はデータアクセスのための人気の高いインタフェースです。 JDBC ドライバーを使用して、標準クライアントから接続できるPostgreSQL エントリポイントを作成することができます。

PostgreSQL データベースとしてSage US data にアクセスするには、CData JDBC Driver for Sage US とJDBC 外部データラッパー(FDW)を使用します。ここでは、FDW をコンパイルしてインストールし、PostgreSQL サーバーからSage US data をクエリします。

JDBC データソースにSage US Data を設定

To connect to Sage US 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.sage50us.Sage50USDriver

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

    The Application Id and Company Name connection string options are required to connect to Sage as a data source. You can obtain an Application Id by contacting Sage directly to request access to the Sage 50 SDK.

    Sage must be installed on the machine. The Sage.Peachtree.API.dll and Sage.Peachtree.API.Resolver.dll assemblies are required. These assemblies are installed with Sage in C:\Program Files\Sage\Peachtree\API\. Additionally, the Sage SDK requires .NET Framework 4.0 and is only compatible with 32-bit applications. To use the Sage SDK in Visual Studio, set the Platform Target property to "x86" in Project -> Properties -> Build.

    You must authorize the application to access company data: To authorize your application to access Sage, restart the Sage application, open the company you want to access, and connect with your application. You will then be prompted to set access permissions for the application in the resulting dialog.

    While the compiled executable will require authorization only once, during development you may need to follow this process to reauthorize a new build. To avoid restarting the Sage application when developing with Visual Studio, click Build -> Configuration Manager and uncheck "Build" for your project.

    ビルトイン接続文字列デザイナー

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

    java -jar cdata.jdbc.sage50us.jar

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

    A typical JDBC URL is below:

    jdbc:sage50us:ApplicationId=8dfafu4V4ODmh1fM0xx;CompanyName=Bellwether Garden Supply - Premium;

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

Sage US Data をPostgreSQL データベースとしてクエリ

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

  1. Log into your database.
  2. Load the extension for the database: CREATE EXTENSION jdbc2_fdw;
  3. Create a server object for Sage US: CREATE SERVER Sage50US FOREIGN DATA WRAPPER jdbc2_fdw OPTIONS ( drivername 'cdata.jdbc.sage50us.Sage50USDriver', url 'jdbc:sage50us:ApplicationId=8dfafu4V4ODmh1fM0xx;CompanyName=Bellwether Garden Supply - Premium;', querytimeout '15', jarfile '/home/MyUser/CData/CData\ JDBC\ Driver\ for\ Salesforce MyDriverEdition/lib/cdata.jdbc.sage50us.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 Sage50US OPTIONS ( username 'admin', password 'test');
  5. Create a foreign table in your local database: postgres=# CREATE FOREIGN TABLE customer ( customer_key text, customer_Name text, customer_LastInvoiceAmount numeric) SERVER Sage50US OPTIONS ( table_name 'customer');
You can now execute read/write commands to Sage US: postgres=# SELECT * FROM customer;
 
 
ダウンロード