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

Part 2 Developing Applications by APIs> Chapter 9 Developing Java Applications> 9.3 How to Use Java APIs> 9.3.2 Data Searches

9.3.2.5 Extracting Record IDs

Record IDs are used to extract, delete, and update the corresponding XML documents. The getRecordID method is used to extract record IDs.

The following diagram shows how a record ID is extracted.

[Figure 9-7 Record ID Extraction]

mark1Sample Code

ShunConnection con = new ShunConnection();
String queryExpression = "/document/base/prefecture == 'Sydney'";
String returnExpression = "/document/base/name, /document/base/price";
ShunPreparedStatement pstmt = con.prepareSearch(queryExpression, returnExpression); (1)
pstmt.setRequest(11,5);                                                             (2)
ShunResultSet rs = pstmt.executeSearch();                                           (3)
while(rs.next()) {                                                                  (4)
  System.out.println("[Record ID] = " + rs.getRecordID());                          (4)
}
rs.close();                                                                         (5)
pstmt.close();                                                                      (5)

con.close();

mark2(1) Create a ShunPreparedStatement Object

Create a ShunPreparedStatement object by specifying a search expression and a return expression as parameters of the prepareSearch method.

Refer to Appendix B Format of Search, Return and Sort Expressions for more information on search expressions and return expressions.

mark2(2) Set the Reply Start Number and the Number of Items to Return per Request

Specify the reply start number and the number of items to return per request in the setRequest method. If the setRequest method is omitted, the number of items to return per request will be set to the value specified in the AnsMax parameter in the conductor or director environment file.

For the number of items to return per request, specify the number of data items to display on each page.

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

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

mark2(4) Extract the Results of the Search

As with extracting search results, always use the next method before extracting a record ID. The next method returns true if there is still more data that can be extracted and false otherwise.

mark2(5) Release the ShunResultSet Object and the ShunPreparedStatement Object

Use the close methods of the ShunResultSet object and the ShunPreparedStatement object to release these objects when they are no longer required.

mark1Sample Codes for Studio

The following sample business class coding shows how to extract a record ID. For the Shunsaku access class, use the prototype created with the Studio interactive wizard. Refer to 9.3.2.2 Obtaining Search Results According to the Number of Data Items for more information on the Shunsaku access class prototype.

Business Class

ShunConnection con = new ShunConnection();

ShunsakuAccessController controller = new ShunsakuAccessController(con);
controller.search(key);
Object[] resultData = 
   controller.getResultData(ShunsakuAccessController.SORT_NONE, 11, 5);
ShunAddressListModel listData = new ShunAddressListModel(resultData);
dataBean.setResultList(listData);

ListModel resultList = dataBean.getResultList();
for(int i = 0; i < resultList.getSize(); i++) {
   Object result = resultList.getElementAt(i);
   AddressData new_result = (AddressData)result;
   String recordID = new_result.getRecordID();
}

controller.close();
con.close();

Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006