ObjectNotFoundException issue

Discussions

EJB programming & troubleshooting: ObjectNotFoundException issue

  1. ObjectNotFoundException issue (5 messages)

    Hi
      I have a problem in which I need to invoke a method on catching "ObjectNotFoundException".Now this invoked method also throws an exception; can I catch it in the same try/catch block ; cause nested try/catch are not allowed any way.

      try
      {
       //find something
       //update if found
       updateRow(arguments)
      }
      catch (ObjectNotFoundException e)
      {
       //insert some data in the database using a method
       // insertRow (which throws an exception insertException)

       insertRow(arguments);
      }
      catch (insertException e) //IS THIS ALLOWED ?????????
      {
      //do some logging
      }
      catch (updateException e)
      {
      //do some logging
      }

      I think this wont work ; cause (insertException) is not thrown in "try" block . what say u?

      Thanks

    Jack


      

    Threaded Messages (5)

  2. ObjectNotFoundException issue[ Go to top ]

    Hi
      I again checked my java knowledge base and its true that once a catch{} has been executed ; all other catch{} are ignored .So I guess "insertException" will be caught by the program which called the current program.
      Can there be any other way of handling this ; I mean the situation in which if an object is not found ; insert it.
      Thanks
    jack
  3. ObjectNotFoundException issue[ Go to top ]

    Hi,

    Let me know if this helps. You can create nested try catch block as follows

    try
    {
    }catch(ObjectNotFoundException onfe)
    {
       try
       {
       }catch(InsertException ie)
       {
       }
    }

    Cheers,
    Devendra
  4. ObjectNotFoundException issue[ Go to top ]

    Hi
      Can i create nested try/catch block?I used to think that nested try/catch blocks are not allowed?
      Is it part of java 1.3? or I was ignorant of it?
    Jack
  5. ObjectNotFoundException issue[ Go to top ]

    this is definitely allowed, i've been using this in jdk1.2.
  6. ObjectNotFoundException issue[ Go to top ]

    Hi
      can a catch block return to the calling program?

      I mean

      try
      {
       return 0 ;
      }
      catch (Exception e)
      {
       return 1 ;
      }


      I guess this is allowed?
      Sorry for this elementary questions ; havent programmed much in java ; so sometimes my fundamentals complain :-)
    Jack