Ready to get started?

Learn more about the CData JDBC Driver for Sage 50 UK or download a free trial:

Download Now

JRuby からSage 50 UK Data にデータ連携

リアルタイムSage 50 UK data に連携するシンプルなJRuby アプリケーションを作成します。

JRuby はRuby プログラミング言語の高性能で安定した、完全にスレッド化されたJava 実装です。CData JDBC Driver for Sage 50 UK を使用すると、JRuby からリアルタイムSage 50 UK data へのデータ連携を簡単に実装できます。ここでは、Sage 50 UK data に接続し、クエリを実行して結果を表示する簡単なJRuby アプリを作成する方法を説明します。

Sage 50 UK Data にJDBC で接続

Before creating the app, note the installation location for the JAR file for the JDBC Driver (typically C:\Program Files\CDatat\CData JDBC Driver for Sage 50 UK\lib).

JRuby natively supports JDBC, so you can easily connect to Sage 50 UK and execute SQL queries.Initialize the JDBC connection with the getConnection function of the java.sql.DriverManager class.

Note: Only Sage 50 UK 2012 and above are supported.

The User and Password properties, under the Connection section, must be set to valid Sage 50 UK user credentials. These values will be the same used to log in to the Sage 50 UK software.

Additionally, the URL property, under the Connection section, will need to be set to the address of the company dataset desired. To obtain the address, do the following:

  1. If you have not already done so, open the Sage 50 UK software.
  2. Click Tools -> Internet Options.
  3. Select the SData Settings tab.
  4. Click the Details button next to Sage 50 Accounts. A window is displayed containing a list of company names along with the address to their corresponding datasets.
  5. Set the URL property to the value in the address field next to the company desired.

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

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

java -jar cdata.jdbc.sage50uk.jar

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

Below is a typical JDBC connection string for Sage 50 UK:

jdbc:sage50uk:URL=http://your-server:5493/sdata/accounts50/GCRM/your-address;User=Manager;

Sage 50 UK Data への接続性を持つJRuby アプリを作成

Create a new Ruby file (for example: Sage50UKSelect.rb) and open it in a text editor.Copy the following code into your file:

require 'java' require 'rubygems' require 'C:/Program Files/CData/CData JDBC Driver for Sage 50 UK 2018/lib/cdata.jdbc.sage50uk.jar' url = "jdbc:sage50uk:URL=http://your-server:5493/sdata/accounts50/GCRM/your-address;User=Manager;" conn = java.sql.DriverManager.getConnection(url) stmt = conn.createStatement rs = stmt.executeQuery("SELECT Name, FinanceBalance FROM TradingAccounts") while (rs.next) do puts rs.getString(1) + ' ' + rs.getString(2) end

With the file completed, you are ready to display your Sage 50 UK data with JRuby.To do so, simply run your file from the command line:

jruby -S Sage50UKSelect.rb

Writing SQL-92 queries to Sage 50 UK allows you to quickly and easily incorporate Sage 50 UK data into your own JRuby applications.Download a free trial today!

 
 
ダウンロード