  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Two phase commit transaction using WSAD5.0 and DB2 | Two phase commit transaction using WSAD5.0 and DB2 2005-04-27 - By Hrishikesh Barua
Back 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@(protected) > 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@(protected) and include in the body of the message "signoff J2EE-INTEREST". For general help, send email to listserv@(protected) and include in the body of the message "help". > >=========================================================================== >To unsubscribe, send email to listserv@(protected) and include in the body >of the message "signoff J2EE-INTEREST". For general help, send email to >listserv@(protected) and include in the body of the message "help". >
=========================================================================== To unsubscribe, send email to listserv@(protected) and include in the body of the message "signoff J2EE-INTEREST". For general help, send email to listserv@(protected) and include in the body of the message "help".
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=iso-8859 (See http://iso-8859.ora-code.com)-1"> <META content="MSHTML 6.00.2800.1106" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <DIV><FONT face=Arial size=2>Hi Anuj,</FONT></DIV> <DIV><FONT face=Arial size=2> </FONT><FONT face=Arial size=2> 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.</FONT></DIV> <DIV><FONT face=Arial size=2> 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).</FONT></DIV> <DIV><FONT face=Arial size=2> Also, the appserver never exposes the actual DataSource from the driver - this is to provide services like connection pooling and transaction management.</FONT></DIV> <DIV><FONT face=Arial size=2> Depending on the appserver, you might also have to mark the datasource as transactional sometimes.</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>Regards</FONT></DIV> <DIV><FONT face=Arial size=2> Hrish</FONT></DIV> <BLOCKQUOTE style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> <DIV style="FONT: 10pt arial">-- -- Original Message -- -- </DIV> <DIV style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> <A title=anujkumar73@(protected) href="mailto:anujkumar73@(protected)">Anuj Kumar</A> </DIV> <DIV style="FONT: 10pt arial"><B>To:</B> <A title=J2EE-INTEREST@(protected) href="mailto:J2EE-INTEREST@(protected)">A mailing list for Java(tm)2 Platform,Enterprise Edition</A> </DIV> <DIV style="FONT: 10pt arial"><B>Cc:</B> <A title=hrishikesh.barua@(protected) .COM href="mailto:hrishikesh.barua@(protected)">Hrishikesh Barua</A> </DIV> <DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, April 27, 2005 12:54 PM</DIV> <DIV style="FONT: 10pt arial"><B>Subject:</B> Re: Re: Two phase commit transaction using WSAD5.0 and DB2</DIV> <DIV><BR></DIV> <P> <BR>hi Harish,<BR>thanx for ur reply but <BR> javax.sql.DataSource db2Datasource = null;<BR>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.<BR>any other solution ???<BR><BR>Thanks and Regards,<BR>Anuj<BR><BR><BR>On Wed, 27 Apr 2005 Hrishikesh Barua wrote :<BR>>Hello,<BR>> 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.<BR>><BR>>Declare<BR>> javax.sql.DataSource db2Datasource = null;<BR>><BR>>Regards<BR>> Hrish<BR>> -- -- Original Message -- --<BR>> From: Anuj Kumar<BR>> To: J2EE-INTEREST@(protected)<BR>> Sent: Wednesday, April 27, 2005 11 :46 AM<BR>> Subject: Two phase commit transaction using WSAD5.0 and DB2<BR>><BR>><BR>><BR>> Hi All,<BR>><BR>> 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<BR>> [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<BR>> at hello.A.getDataSource(A.java:196)<BR>><BR>> while looking up and casting the DB2XADatasource.<BR>><BR>> My method which is supposec to return DB2XADatasource is..<BR>><BR>> public static DB2XADataSource getDataSource(String jndiName) {<BR>><BR>> InitialContext ctx = null;<BR>> DB2XADataSource db2Datasource = null;<BR>> Connection conn = null;<BR>><BR>> try {<BR>> ctx = new InitialContext();<BR>><BR>>   ; db2Datasource = (DB2XADataSource) ctx.lookup(jndiName);<BR>><BR>><BR>> } catch (NamingException ne) {<BR>> ne.printStackTrace();<BR>> }<BR>><BR>> return db2Datasource ;<BR>>   ; }<BR>><BR>> }<BR>><BR>> can anyone Help me out ???<BR>><BR>> Thanks a lotttt<BR>> Anuj<BR>><BR>><BR>><BR>><BR>> =========================================================================== To unsubscribe, send email to listserv@(protected) and include in the body of the message "signoff J2EE-INTEREST". For general help, send email to listserv@(protected) and include in the body of the message "help".<BR>><BR>>====================================================== =====================<BR>>To unsubscribe, send email to listserv@(protected) and include in the body<BR>>of the message "signoff J2EE-INTEREST". For general help, send email to<BR>>listserv@(protected) and include in the body of the message "help".<BR>><BR></P><BR><BR><A href="http://clients.rediff.com/signature/track_sig.asp" target=_blank><IMG hspace=0 src="http://ads.rediff.com/RealMedia/ads/adstream_nx.cgi/www.rediffmail.com /inbox.htm@(protected)" border=0></A> </BLOCKQUOTE></BODY></HTML> =========================================================================== To unsubscribe, send email to listserv@(protected) and include in the body of the message "signoff J2EE-INTEREST". For general help, send email to listserv@(protected) and include in the body of the message "help". <p>
|
|
 |