この記事では、WooCommerce JDBC ドライバーを使用してPowerBuilder からWooCommerce にアクセスする方法を説明します。
CData JDBC Driver for WooCommerce は、標準ベースのコントロールであり、PowerBuilder を含むJDBC をサポートするプラットフォームまたは開発テクノロジーから使用できます。 また、PowerBuilder でCData JDBC Driver for WooCommerce を使用する方法についても詳しく説明します。
この記事では、CData JDBC Driver for WooCommerce を使用して読み取りと書きこみを実行する基本的なPowerBuilder アプリケーションを作成する方法を説明します。
PowerBuilder からWooCommerce データに接続
以下のステップに従ってDatabase Painter ツールを使用し、JDBC URL for WooCommerce に基づいてデータベースプロファイルを作成します。データベースプロファイルを使用して、接続プロパティを保存できます。Ⅾatabase Painter では、データをグラフィカルに操作したり、SQL クエリを実行したりできます。
ドライバーJAR をPowerBuilder クラスパスに追加します。CLASSPATH システム環境変数を、インストールディレクトリのlib サブフォルダにあるドライバーJAR へのパスに設定します。
NotePowerBuilder Classic を使用している場合は、[Tools]->[System Options]->[Java]をクリックし、ドライバーJAR へのパスを追加することもできます。
- [Tools]->[Database Painter]と進みます。
- JDBC のノードを右クリックし、[New Profile]をクリックします。
- [Database Profile Setup]ダイアログで、以下を入力します。
- Profile Name:プロファイルのわかりやすい名前を入力します。
- Driver Name:ドライバーのクラス名にcdata.jdbc.woocommerce.WooCommerceDriver を入力します。
- URL:JDBC URL を入力します。
WooCommerce supports the following authentication methods: one-legged OAuth1.0 Authentication and standard OAuth2.0 Authentication.
Connecting using one-legged OAuth 1.0 Authentication
Specify the following properties (NOTE: the below credentials are generated from WooCommerce settings page and should not be confused with the credentials generated by using WordPress OAuth2.0 plugin):
- ConsumerKey
- ConsumerSecret
Connecting using WordPress OAuth 2.0 Authentication
- テーブルを表示および編集するには、テーブルを右クリックして[Edit Data]->[Grid]をクリックします。

WooCommerce をPowerBuilder Controls と共に使用する
標準のPowerBuilder オブジェクトを使用してJDBC データソースに接続し、クエリを実行できます。以下の例は、WooCommerce をDataWindowに取得する方法を示しています。次のコードをopen メソッドに追加できます。
SQLCA.DBMS = "JDBC"
SQLCA.AutoCommit = False
SQLCA.DBParm = "Driver='cdata.jdbc.woocommerce.WooCommerceDriver',URL='jdbc:woocommerce:Url=https://example.com/; ConsumerKey=ck_ec52c76185c088ecaa3145287c8acba55a6f59ad; ConsumerSecret=cs_9fde14bf57126156701a7563fc87575713c355e5; InitiateOAuth=GETANDREFRESH";
CONNECT USING SQLCA;
dw_orders.SetTransObject(SQLCA);
dw_orders.Retrieve();