• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to catch exception in EJB

 
apurva mehta
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using entity bean & session bean in my project my session bean calls the entity bean .My problem is that when i pass a string parameter in findByPrimaryKey(String) and if it does not exist then javax.ejb.ObjectNotFoundException is thrown now i want to catch this exception ...i tried alot but am not able to catch it.....
is there any means to catch the exception.
Please help as early as possible....
thanx in advance ...
regards ,
Apurva.
 
umar hathab
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I hope u are forming the query and call executeQuery() inside findBy() method.When u get the ResultSet, call rs.next() method .If that method returns false,there is no record in database and throw ObjectNotFoundException with some message.If there is some record get it and catch SQLException.Inside catch throw EJBException.Hope this may help u.
A.UMAR HATHAB
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apurva, are you using CMP or BMP?
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
 
apurva mehta
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi kyle,
I am using CMP entity bean,
thanx for reply,
regards ,
apurva.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!