It is responsibility of transaction manager. Transaction manager that is
implemented
by the app server binds the current thread with the transaction context.
Even if you return the connection back to connection pool, actually
transaction
manager will not return the connection back to pool until transaction is
complete.
Instead it keeps that connection open and reference to that connection is
stored in
transaction context's transaction object.
Now when you get a new connection within same thread transaction manager
will check if there
is any transaction associated to calling thread, if yes it will use previous
connection
and not the new connection. This is one of the reason that ejb spec does not
allow to
create new threads within ejb.
Hope that helps
-----Original Message-----
From: krithikav [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 20, 2001 3:19 PM
To: [EMAIL PROTECTED]
Subject: Re: Doubt in CMT
Hi,
Usually for any transaction, a connection to a database is opened and then
the transaction is started. However in my program, I tried to open a
database connection after the begin method of UserTransaction interface of
jta. I did not get any error though I was expecting one. The transaction did
a commit successfully. Can anyone explain how this connection gets
associated with the transaction even if it is opened after the transaction
has begun?
Regards,
Krithika
-----Original Message-----
From: James Cook [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 20, 2001 7:01 PM
To: [EMAIL PROTECTED]
Subject: Re: Doubt in CMT
Smoke and mirrors. The connection.close() does not actually close.
Even if they do close in some implementations, they register themselves with
a
TransactionManager that is in charge of issuing the final commit to all of
the
resources involved in the transaction.
jim
----- Original Message -----
From: "krithikav" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, April 20, 2001 8:59 AM
Subject: Doubt in CMT
> Hi,
> I have a doubt in the basic concept of Container Managed Transaction.
> In one of the business method(with transaction attribute: TX_REQUIRED) of
my
> EJB, I
> do the following:
>
> open a connection to the database
> try{
> update table A
> update table B
> }
> catch (Exception e)
> {
> close the connection
> throw a remote exception
> }
> close the connection.
>
> Now if the update to the table B fails and it results in an exception and
> then I close the connection and throw a remote exception to the container,
> how will the container rollback the entire transaction when the connection
> is closed and it is no longer available for the container.
>
> Regards,
> Krithika
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff EJB-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".