Interstage Shunsaku Data Manager Application Development Guide - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX - |
Contents
Index
![]() ![]() |
Part 2 Developing Applications by APIs | > Chapter 9 Developing Java Applications | > 9.3 How to Use Java APIs | > 9.3.2 Data Searches |
When searching for a particular XML document, do not obtain the entire document immediately. Instead, start by obtaining the partial information that can effectively identify the document.
The user can then use this partial information to pick out the desired XML document and obtain detailed information. To extract an entire XML document, use the record ID that is returned when the partial information is extracted. Using a record ID enables desired entire XML documents to be extracted.
The following diagram shows the process for using record IDs to obtain an entire XML document.
ShunConnection con = new ShunConnection(); ShunPreparedRecordID prid = con.prepareSearchRecordID(); (1) prid.add(recordID); (2) ShunResultSet rs = prid.searchByRecordID(); (3) while (rs.next()) { (4) System.out.println("[Result] = " + rs.getString()); (4) } rs.close(); (5) prid.close(); (5) con.close(); |
Use the prepareSearchRecordID method to create a ShunPreparedRecordID object.
Use the add method to specify the record ID. Record IDs can be obtained using the getRecordID method.
Multiple record IDs can be specified with the add method. Any existing record IDs will be overwritten if they are specified again.
By specifying multiple record IDs with the add method, multiple XML documents can be obtained at once.
Execute the search using the searchByRecordID method. A ShunResultSet object will be created to hold the results of the search.
Always invoke the next method before extracting the results of the search. The next method returns true if there is still more data that can be extracted and false otherwise.
Different methods can be used to extract XML documents for different objectives. The following table shows the methods that can be used.
Method |
Function |
---|---|
getString |
Extracts XML documents as String objects. |
getStream |
Extracts XML documents as InputStream objects. |
Use the close methods of the ShunResultSet object and the ShunPreparedRecordID object to release these objects when they are no longer required.
The following sample code shows how to use a record ID to extract an entire XML document in the case of the business class and the Shunsaku access class.
ShunConnection con = new ShunConnection(); ShunsakuAccessController controller = new ShunsakuAccessController(con); Object[] resultData = controller.detail(recordID); controller.close(); con.close(); |
public Object[] detail(String recordID) throws ShunException { Object[] resultData = null; ShunPreparedRecordID prid = con.prepareSearchRecordID(); (1) prid.add(recordID); (2) ShunResultSet rs = prid.searchByRecordID(); (3) try { resultData = paeseResultSet(rs); (4) } finally { rs.close(); (5) } prid.close(); (5) return resultData; } |
Contents
Index
![]() ![]() |