Ubuntu Linuxから Oracle SE One へ接続方法(TFDConnection)[JAPAN]
毛利です。
Ubuntu Linux(Delphi)からAWS(RDS) Oracle SE Oneへの接続方法
[Instant Client ダウンロード]
Instant Client 12.2を下記のURLからダウンロードします。
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
テストしたのは instantclient-basic-linux.x64-12.2.0.1.0.zip です。
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html#ic_x64_inst
まず ダウンロードしたinstantclient-basic-linux.x64-12.2.0.1.0.zipファイルをLinux上で解凍します。
# unzip instantclient-basic-linux.x64-12.2.0.1.0.zip
/opt/oracleディレクトリを作成し解凍したファイルを移動します。
# mkdir /opt/oracle mv instantclient_12_2 /opt/oracle/
libclntsh.so, libocci.soファイルのリンクを作成
# ln -s libclntsh.so.12.1 libclntsh.so ln -s libocci.so.12.1 libocci.so
環境変数の設定
# export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2:$LD_LIBRARY_PATH export PATH=/opt/oracle/instantclient_12_2:$PATH
これでOracle Instant ClientのUbuntu Linux側の設定はOKです。
PAServer-19.0を起動します。
http://docwiki.embarcadero.com/RADStudio/Tokyo/ja/Linux_アプリケーション開発
# ./PAServer-19.0/paserver
RAD Studio 10.2 Tokyoを起動し、新規プロジェクト →その他→Delphi→WebBroker→Webサーバーアプリケーション
Linuxにチェックします。
スタンドアロン コンソール アプリケーションを選択
TWebModule1が作られていますので デザイン画面から
TFDConnection, TFDPhysOracleDriverLink, TFDQuery, TFDStanStorageJSONLinkを配置します。
予め用意したAWS(RDS) Oracle SE Oneのインスタンス内にtable1テーブルを用意しました。
このFDQuery1をJSONでRESTできるよう 次のようなコードを書きます。
// procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); var ms_: TMemoryStream; begin FDQuery1.Active := True; ms_ := TMemoryStream.Create; FDQuery1.SaveToStream(ms_, TFDStorageFormat.sfJSON); ms_.Position := 0; Response.ContentStream := ms_; end; procedure TWebModule1.WebModuleCreate(Sender: TObject); begin FDPhysOracleDriverLink1.VendorLib := '/opt/oracle/instantclient_12_2/libclntsh.so'; FDConnection1.Connected := True; end;
プロジェクトオプション内のデバッガ部"/usr/bin/xterm "を使用するにチェックします。
// /usr/bin/xterm -e "%debuggee%"
[実行]
table1テーブルの内容をJSON形式でブラウザ表示できている事が確認できます
WindowsからUbuntu側のプロジェクトに接続


Comments
-
Please login first in order for you to submit comments