Using EJBs and JDBC transactions inside servlets
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Samyukta_Rao
Posted On:   Friday, May 18, 2001 10:06 AM

Hi, I have a problem which involves mixing EJBs with legacy JDBC code. There is one Stateless Session EJB , which uses several CMP Entity beans . This Session EJB is being called from a servlet , and needs to operate within a JDBC transaction. Is there some way to make it possible ? The code is something like this : Connection con = null ; con= makeJDBCConAndStartTransaction(); try { method1UsesJDBC(con); callSessionEJB(); method2UsesJDBC(con); } catch(Exception e){ rollbackAndDestroyJDBCTransaction(con);    More>>

Hi,


I have a problem which involves mixing EJBs with legacy JDBC code.



There is one Stateless Session EJB , which uses several CMP Entity beans .
This Session EJB is being called from a servlet , and needs to operate within a JDBC transaction. Is there some way to make it possible ?


The code is something like this :


Connection con = null ;


con= makeJDBCConAndStartTransaction();


try {


method1UsesJDBC(con);



callSessionEJB();



method2UsesJDBC(con);



}


catch(Exception e){


rollbackAndDestroyJDBCTransaction(con);


//how can I rollback the EJB here ??


}


--------------

If the EJB had been the last called , there would not have been a problem. Unfortunately, it has to be sandwiched between two JDBC calls. Nor can I move method 2 into the EJB .


If it is not possible with Stateless EJB, then is there a solution if it were made Stateful ?


I would like to avoid using BMP .



Thanks


Samy

   <<Less

Re: Using EJBs and JDBC transactions inside servlets

Posted By:   Anonymous  
Posted On:   Friday, May 18, 2001 10:10 AM

Yes, I think that using a Statefull Session Bean will make the trick.

You can maintain the conversational state with the client, and if you put all the loging in it, then you will be able to act on the Entity bean based on the result of the transaction.

Regards.
About | Sitemap | Contact