Hi,

I am having a code which fetches say 200 records,after 6 records i got an exception..So after my exception is caught in catch block i have 2 call a method which can help continuing the exception starting from the 7th object.
Can anyone help with some piece of code that can help me do this??? Hoping for a favorable response

Regards
Arathy Nair

Can you post the code that you are having problems with.
Pseudo code:
begin loop
get next record
process record possibly causing an exception
handle exception
end loop

try {

            CURRENT_SESSION = new CommonHandlers().connect();

            //query to fetch all the MUI Finding objects based on status type
            IQuery query =(IQuery)CURRENT_SESSION.createObject(IQuery.OBJECT_TYPE,QualityChangeRequestConstants.CLASS_AUDITS_CLASS); 
            query.setCaseSensitive(false); 
            String sCriteria = "[Audit.Audit ID] contains ('L2') AND [Audit.Status] Equal To ('$STATUSTYPE.RELEASED') OR [Audit.Status] Equal To ('$STATUSTYPE.COMPLETE')";
            query.setCriteria(sCriteria);           
            ITable results = query.execute(); 

            results.setPageSize(200);
            // If Result  is obtained iterate through the result table.
              if(results != null && !results.isEmpty()){

                  Iterator objIt = results.iterator();
                  IDataObject auditObj = null;
                  boolean relFlag = false;
                  int relCount = 0;
                   while(objIt.hasNext()) {
                     // load the object
                    auditObj = (IDataObject)((IRow)objIt.next()).getReferent();
                    // System.out.println("printing the audit objects "+auditObj.getAgileClass());
                    IQualityChangeRequest affObj = (IQualityChangeRequest)auditObj;
                     String baseName = affObj.getName();
                     IDataObject baseObject = auditObj;
                     String status =  ( affObj).getStatus().toString();
                     IAgileClass cls = affObj.getAgileClass();
                     String newStatus ="";
                     String strStatus ="";

                     if(cls.toString().equalsIgnoreCase("Audit - Level 2")) {

                         strStatus = RESOURCE_DATA.getString("Status_Audit");

                     }
                     StringTokenizer st =new StringTokenizer(strStatus,",");
                     while(st.hasMoreTokens()){
                         newStatus = st.nextToken();
                         if(status.equalsIgnoreCase(newStatus)){
                             String fndName = null;
                             //Getting the file path and checking whether the directory exists or not
                                String NewFile = FILE+baseObject.getAgileClass()+"\\";
                                String dirName = NewFile + baseName;
                                File dir2 = new File(dirName);
                                if(dir2.exists()){
                                 System.out.println("directory exists");
                                 File[] files = dir2.listFiles();
                                 System.out.println("file length :"+files.length);
                                 for(int i =0;i<files.length;i++){
                                     System.out.println("the file name is "+files[i].getName());
                                     //checking if an objectname_error folder exists or not?
                                    if(files[i].getName().equalsIgnoreCase(dirName+"_error"+"\\")){
                                         System.out.println("Error folder exists");
                                        getValueFromProperty(auditObj,relFlag,relCount,fndName,baseName,baseObject);
                                         getRelatedFindings(auditObj,relFlag,relCount);
                                    }
                                    else{
                                        //if there is no audit error folder checking for its findings
                                         getRelatedFindings(auditObj,relFlag,relCount);
                                    }
                                }
                                }
                                //if the directory does not exist before fetching the objects and creating the new folder structure
                                else{   

                                getValueFromProperty(auditObj,relFlag,relCount,fndName,baseName,baseObject);
                             getRelatedFindings(auditObj,relFlag,relCount);
                                }            
                         }              
                     }
                   }
              }

        } catch (APIException ae) {
            // Catch API Exception if any
            ae.printStackTrace();
            String excepMsg = "*********An API Exception has occured and the message is "+ae.getMessage() +"************************";
            logger.info(excepMsg);
            logger.debug(excepMsg);



        } catch (Throwable t) { // Catch Exception if any
              logger.info("********Caught the throwable error "+t.getMessage()+"************************");
               logger.debug("**************Caught the throwable error "+t.getMessage()+"************************");
            //e.printStackTrace();
            t.printStackTrace();

        } finally {
            logger.debug("****************Closing the Agile Session****************");
            logger.info("*************Closing the Agile Session************");
            CURRENT_SESSION.close();

        }
 }

Where is the loop that would surround the getting of the next record and the processing of the record?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.