Interstage Shunsaku Data Manager Application Development Guide - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX -
Contents Index PreviousNext

Part 1 The Basic for Developing Application> Chapter 6 Direct Access Function> 6.4 Searching Data by Direct Access Key

6.4.1 For Java API

The searchByKey method is used in the direct search for Java API.

The following figure shows a flow of the direct search for Java API.

[Figure 6-4 A flow of the direct search]

mark1Sample Code

ShunConnection con = new ShunConnection();

ShunPreparedKey preSkey = con.prepareSearchKey("key1", "/");             (1)
preSkey.add("20061101,00000001");                                        (2)
preSkey.add("20061101,00000002");                                        (2)
preSkey.add("20061101,00000003");                                        (2)
preSkey.setSearchType(ShunPreparedKey.SHUN_KEY_COMPLETE_MATCH);
ShunResultSet rs = preSkey.searchByKey();                                (3)
System.out.println("[Number of results] = " + rs.getReturnCount());  
while (rs.next()) {
  System.out.println("[Result] = " + rs.getString());
}
rs.close();
preSkey.close();                                                         (4)

con.close();

mark2(1) Create a ShunPreparedKey Object

Create a ShunPreparedKey object by specifying a direct access key and a return expression as parameters of the prepareSearchKey method.

mark2(2) Set the direct access key

Set the direct access key using the add method.

Multiple direct access keys can be set by using add method.

Specify multiple direct access keys with the Add method to obtain multiple XML documents at a time.

mark2(3) Execute the Search (Create a ShunResultSet Object)

Execute the search using the searchByKey method. A ShunResultSet object will be created to hold the results of the search.

mark2(4) Release the ShunPreparedKey Object

Use the close method of the ShunPreparedKey object to release the object when it is no longer required.

Refer to F.3.2 Searching Data Using Direct Access Key for the sample program of the direct process.

Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006