アプリケーションの SQL ステートメントを DB2® パッケージに実行時にバインドするには、 com.ibm.pdq.tools.StaticBinder クラスの bind() メソッドを使用します。 このメソッドは、バインド操作が失敗すると値 FALSE を返し、バインド操作が正常に実行されると値 TRUE を返します。
このメソッドは 2 つのパラメーターを取ります。 最初のパラメーターは、引数を StaticBinder ユーティリティーに渡すためのストリング配列です。 2 番目のパラメーターは、StaticBinder ユーティリティーがメッセージおよび例外を出力する先の PrintWriter オブジェクトです。
bind() メソッドの呼び出し例を以下に示します。
StaticBinder binder = new StaticBinder (); PrintWriter out = new PrintWriter( new FileWriter("BinderOutput.txt")); String[] argsArray = {"-user","username","-password","password", "-url","JDBC-URL","-pureQueryXml","pureQueryXML-file|pureQueryXML-file:base-package-name"}; Boolean check=binder.bind(argsArray, out);