I think, therefore I exist -- Rene Descartes
Thanks,<br />Bhanu<br />SCEA Step-I<br />SCBCD for J2EE 1.3<br />SCJP1.4
I think, therefore I exist -- Rene Descartes
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Sreenivasa Majji
Why can't a(), b() and c() each obtain a Connection and close it in a finally block? After all, you will usually want to close a Connection as soon as possible so that it can be returned to the pool.
I think, therefore I exist -- Rene Descartes
I think, therefore I exist -- Rene Descartes
Thanks,<br />Bhanu<br />SCEA Step-I<br />SCBCD for J2EE 1.3<br />SCJP1.4
Originally posted by Valentin Tanase:
Hi Sreenivasa,
If you use BMT then you have two solutions: either to use jdbc transactions (using commit/rollback methods on the Connection object), or to use jts/jta transactions (using the UserTransaction object). If you chouse jta, then your dao classes cannot commit a transaction using Connection.commit(), because an exception will be thrown. You have to use UserTransaction.begin()/Commit()/rollback(). If you do that then you�ll design nested transactions and this is not supported by j2ee either. Hence with BMT your design is limited to use jdbc transactions. In that case, if each one of these methods commits the transaction, then it�s nothing much you can do about. They are independent transactions and one commits/rollback without caring much about the others.
Finally if the container manages the transaction (using CMT) then your code is not allowed to commit transactions at all. By doing so the container will raise an exception.
Answering to your questions I would say 1) yes, 2) no.
Regards.
Sreenivasa Majji
Imagine I am using CMT.
Then what I have to do in the DAOs?
Just get the connection, and perform some update/insert and close the connection? No commt/rollback in DAOs?
If so, when the commit will occur?
If there are no exceptions/errors the transaction commits itself automatically???
I am trying to understand CMT,JDBC,BMT and JTA transactions how they all work together.
I think, therefore I exist -- Rene Descartes
I think, therefore I exist -- Rene Descartes
Originally posted by Valentin Tanase:
Hi Sreenivasa ,
Good luck, you are on the right track.
Regards.
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
As mentioned earlier if I am using the Below archieture.
Action - Session Bean - DAO -DB
I have decided to manage my transcation using session bean.
But as you said container rolls back the transcation only on occurance of
a Run Time Exception (that is probably SQLException)
But I have many checked Application Exceptions thrown by my DAO.
In this case I have to handle the tanscation.(How do i do it in session bean to rollback the transcation on my application exceptions)
I think, therefore I exist -- Rene Descartes
if I called a stored procedure in DAO method DAO.b(), and the database transaction was committed at the end of this stored procedure, later DAO.c() raise a RuntimeException, then Container would rollback the transaction, but would it be able to rollback the already commited database transaction in the stored procedure called by DAO.b()?
I think, therefore I exist -- Rene Descartes
Sreenivasa Majji
Originally posted by Roger Chung-Wee:
This may be useful..https://coderanch.com/t/316284/EJB-JEE/java/Remote-Exception
The only time you will want to handle an application exception is if you know that the client does not expect it and/or cannot recover from it. In such a case, wrap the application exception in javax.ejb.EJBException and throw it. Otherwise, which should be most of the time, just duck the application exception and let the client deal with it.
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Thank you all the great replies.
I have been struggling to get reliable answers long time, now I knew where to look for the right answers.
Great job.
Thank you.
I think, therefore I exist -- Rene Descartes
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Originally posted by Valentin Tanase:
You.re very welcome Sreenivasa. I’m glad I could help
![]()
Originally posted by Valentin Tanase:
You.re very welcome Sreenivasa. I’m glad I could help
![]()
In my stateless session bean ejb.xml file can i say that for some methods in session bean i want the container to manage the transcations as they are global and for other session bean methods disable transcation.
How can i define a transcation boundary if I am using the below archieture
Action-Session bean-DAO-DB
How do i define transcation boundry in this case.
Without using Spring or any other frameworks.
I think, therefore I exist -- Rene Descartes
In my stateless session bean ejb.xml file can i say that for some methods in session bean i want the container to manage the transcations as they are global and for other session bean methods disable transcation.
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|