Sample Program Using the Common Client Interface

Finally, take a quick look at an application that uses the Common Client Interface to interact with a fictitious library database and search for the book titled Teach Yourself WebLogic Server 7.0. The application takes the title of the book to be searched as a parameter. It executes the procedure BOOK_RECORD, passing the book title as the parameter. It retrieves the output in the form of a record and iterates the record to retrieve the data. Remember, this is just a sample code snippet and not an actual working code.

 Class MyCCISampleApp  {     public static void main(String args[])     {         String bookToSearch = new String();         Object outputObj = null;         // get the book title to search         bookToSearch = args[0];         try         {             // get connection to the EIS             ConnectionSpec eisConSpec =                     new CciConnectionSpec(user, password);             eisCon = eisConFactory.getConnection(eisConSpec);             // prepare for interaction             Interaction eisInteractionObj =                     eisCon.createInteraction();             InteractionSpec eisInteractionSpecObj =                     new CciInteractionSpec();             // set the interaction parameters             eisInteractionSpecObj.setSchema(user);             eisInteractionSpecObj.setCatalog(null);             eisInteractionSpecObj.setFunctionName(                     "SEARCH_BOOK");             // create the input record             RecordFactory eisRF =                     eisConFactory.getRecordFactory();             IndexedRecord eisIndexedRec =                     eisRF.createIndexedRecord("BOOK_RECORD");             // set the parameter to search in the input record             eisIndexedRecord.add(new String(bookToSearch));             Record eisOuputRecord = null;             // execute the interaction             eisOutputRecord =                     eisInteractionObj.execute(                     eisInteractionSpecObj, eisIndexedRec);             // retrieve the result of the search and print it             Iterator oI = eisOutputRecord.iterator();             while(oI.hasNext())             {                 outputObj = oI.next();                 if(outputObj instanceof BigDecimal)                     System.out.println("Book price: " +                             ((BigDecimal)outputObj).floatValue());                 if(outputObj instanceof String)                     System.out.println("Book title: " +                             outputObj);             }             // close the connection to the EIS             eisCon.close();         }         catch(ResourceException rex)         {             System.out.println("Exception occurred: " +                     rex.printStackTrace());         }     } } 


Sams Teach Yourself BEA WebLogic Server 7. 0 in 21 Days
Sams Teach Yourself BEA WebLogic Server 7.0 in 21 Days
ISBN: 0672324334
EAN: 2147483647
Year: 2002
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net