IntelliJ Java IDE
The moose likes EJB and Other Java EE Technologies and the fly likes how to catch exception in EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » EJB and Other Java EE Technologies
Reply Bookmark "how to catch exception in EJB" Watch "how to catch exception in EJB" New topic
Author

how to catch exception in EJB

apurva mehta
Ranch Hand

Joined: Nov 21, 2001
Posts: 35
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

Joined: Aug 20, 2001
Posts: 52
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


Sun Certified Java Programmer for Java 2.0 (93%) <p>----Winners always make the learning a habit
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3878
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.


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
apurva mehta
Ranch Hand

Joined: Nov 21, 2001
Posts: 35
hi kyle,
I am using CMP entity bean,
thanx for reply,
regards ,
apurva.
 
 
subject: how to catch exception in EJB
 
Threads others viewed
Container Managed Transactions
EJB (CMP) performance ... why so slow?
setRollbackOnly not working
Help required(Exceptions)
unable to catch EJBException from ejbstore in facade
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com