| Apdesigner プログラマーズガイド |
目次
索引
![]()
|
| 第3部 Apdesigner利用編 | > 第12章 データベース処理を作成する | > 12.3 Interstage Shunsakuを使用する |
アクセスクラスとデータクラスは、Interstage ShunsakuのAPIと組み合わせて利用します。
以下にクラスを利用した例を示します。
|
クラス名 |
説明 |
|---|---|
|
ShunAccessController |
アクセスクラスです。 |
|
SoftwareData |
データクラスです。 |
|
ShunConnection |
Interstage Shunsakuとコネクションを接続するInterstage ShunsakuのAPIです。 |
public static void main(String[] args) {
ShunConnection connection = null;
ShunAccessController accessController = null;
try {
// ShunConnectionオブジェクトを作成する
connection = new ShunConnection("localhost", 33101);
// ShunAccessControllerオブジェクトを作成する
accessController = new ShunAccessController(connection);
// 検索文字列で検索する
accessController.searchOs("Windows");
// 結果を取得する
Object[] resultData;
int i;
SoftwareData software;
resultData = accessController.getResultData(ShunAccessController.SORT_NAME);
for (i = 0; i < resultData.length; i++) {
if (resultData[i] instanceof SoftwareData) {
software = (SoftwareData)resultData[i];
System.out.println("名前[" + i + "] = " + software.getName());
}
}
}
catch (ShunException ex1) {
System.err.println(ex1.getMessage());
}
finally {
try {
if (accessController != null) {
accessController.close();
}
}
catch (ShunException ex2) {
System.err.println(ex2.getMessage());
}
finally {
try {
if (connection != null) {
connection.close();
}
}
catch (ShunException ex3) {
System.err.println(ex3.getMessage());
}
}
}
}
目次
索引
![]()
|