HI Anuj,
I'm assuming that you've read
that article in the link you posted carefully. Please note the following points
that it mentions - (I'm quoting)
1. With distributed
transactions, the Connection.commit or Connection.rollback methods do not indicate transaction
boundaries. Instead, your applications let the application server manage
transaction boundaries.
2. the application
server rolls back all the work done by all EJBs
<This means that the TM in this case is not your
application, but the application server>
3. illustrates a program
that uses JTA methods to execute a distributed transaction. This program acts as
the transaction manager and a transactional application
<The key thing to note in the last point is that
the program itself is acting as a TM. If you're using an appserver, the
appserver is the TM.>
Based on your requirements, you can use either, but
you cannot mix the two.
Regards
Hrish
----- Original Message -----
Sent: Wednesday, April 27, 2005 2:13
PM
Subject: Re: Two phase commit transaction
using WSAD5.0 and DB2
hi harish,
thanks for ur concern but for implementing
distributed transaction that uses the JTA , Application programmers has to use
either XADateSource or any database specific Api.
if u wanna more abt it u
can go thru
http://publib.boulder.ibm.com/infocenter/db2help/index.jsp?topic=/com.ibm.db2.udb.doc/ad/cjvdstxx.htm
Thanks
and Regards,
Anuj
On Wed, 27 Apr 2005 Hrishikesh Barua wrote
:
>Hi Anuj,
> Application
programmers are not supposed to use the XADataSource interface directly - it's
used by the TransactionManager internally (in this case, the TM inside your
appserver). You should use the DataSource interface in your application - and
the appserver will take care of the transaction management transparently,
provided you use either the declarative or programmatic model.
>
If you're using EJB's you can use either of them; if you're using web
components you can use the UserTransaction API to manage your transactions.
You datasource will automatically participate in those transactions (it's the
responsibility of the appserver to make it participate in 2PC).
>
Also, the appserver never exposes the actual DataSource from the driver - this
is to provide services like connection pooling and transaction
management.
> Depending on the appserver, you might also have to
mark the datasource as transactional
sometimes.
>
>Regards
> Hrish
> -----
Original Message -----
> From: Anuj Kumar
> To: A
mailing list for Java(tm)2 Platform,Enterprise Edition
> Cc:
Hrishikesh Barua
> Sent: Wednesday, April 27, 2005 12:54
PM
> Subject: Re: Re: Two phase commit transaction using WSAD5.0
and DB2
>
>
>
> hi Harish,
> thanx
for ur reply but
>
javax.sql.DataSource db2Datasource = null;
> does not work in this
case since i need the instance of either DB2XADataSource or XADataSource class
to proceed with 2 phase commit transaction Api's and DB2XADatasource class
does not implement DataSource so we can't type cast too.
> any
other solution ???
>
> Thanks and Regards,
>
Anuj
>
>
> On Wed, 27 Apr 2005 Hrishikesh Barua wrote
:
> >Hello,
> > You should cast the object
that you look up to a javax.sql.DataSource object. Using any proprietary APIs
means your app will not run on any other appserver. In this case the object
that you get back from the lookup is a WAS datasource wrapper - which is
correct.
> >
> >Declare
> >
javax.sql.DataSource db2Datasource =
null;
> >
> >Regards
> >
Hrish
> > ----- Original Message -----
>
> From: Anuj Kumar
> > To:
J2EE-INTEREST@JAVA.SUN.COM
> > Sent: Wednesday, April 27,
2005 11:46 AM
> > Subject: Two phase commit transaction
using WSAD5.0 and DB2
> >
> >
>
>
> > Hi All,
> >
>
> I am trying to implement (prototype) 2 phase commit transaction
protocol using wsad5.1 and db2.i configured the DB2XADatasource provider in
wsad and when i try yo run my program i get
> > [4/27/05
11:27:13:296 GMT+05:30] 1accbc8a WebGroup E SRVE0026E:
[Servlet Error]-[A]: java.lang.ClassCastException:
com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource
> >
at hello.A.getDataSource(A.java:196)
>
>
> > while looking up and casting the
DB2XADatasource.
> >
> > My method which
is supposec to return DB2XADatasource is..
> >
>
> public static DB2XADataSource getDataSource(String jndiName)
{
> >
> >
InitialContext ctx = null;
> >
DB2XADataSource db2Datasource = null;
>
> Connection conn =
null;
> >
> >
try {
> >
ctx = new InitialContext();
>
>
> >
db2Datasource = (DB2XADataSource) ctx.lookup(jndiName);
>
>
> >
> >
} catch (NamingException ne) {
> >
ne.printStackTrace();
>
> }
>
>
> > return
db2Datasource ;
> > }
>
>
> > }
> >
> >
can anyone Help me out ???
> >
> > Thanks
a lotttt
> > Anuj
> >
>
>
> >
> >
> >
=========================================================================== To
unsubscribe, send email to listserv@java.sun.com and include in the body of
the message "signoff J2EE-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message
"help".
> >
>
>===========================================================================
>
>To unsubscribe, send email to listserv@java.sun.com and include in the
body
> >of the message "signoff J2EE-INTEREST". For
general help, send email to
> >listserv@java.sun.com and
include in the body of the message "help".
>
>
>
>
>
>
>
>===========================================================================
>To
unsubscribe, send email to listserv@java.sun.com and include in the
body
>of the message "signoff J2EE-INTEREST". For general help,
send email to
>listserv@java.sun.com and include in the body of the
message "help".
>
=========================================================================== To
unsubscribe, send email to listserv@java.sun.com and include in the body of
the message "signoff J2EE-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff J2EE-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".