Kesav,
If I explicitly use con.commit();
then this works fine...
Just have a look at the modified code now...
package twophase;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.transaction.UserTransaction;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import java.sql.*;
public class TwoPhaseBean implements SessionBean
{
public boolean doTransaction(String id,String name,String balance){
try{
InitialContext IC = new InitialContext();
UserTransaction ut =
(UserTransaction)javax.rmi.PortableRemoteObject.narrow(IC.lookup("java:comp/
UserTransaction"),javax.transaction.UserTransaction.class);
System.out.println("Got the
UserTransaction::"+ut.toString());
DataSource ds =
(DataSource)javax.rmi.PortableRemoteObject.narrow(IC.lookup("java:OracleDS")
,javax.sql.DataSource.class);
System.out.println("Got the
Datasource::"+ds.toString());
Connection con = ds.getConnection();
con.setAutoCommit(false);
Statement stmt = con.createStatement();
ut.begin();
System.out.println("insert into bank values
('"+id+"','"+name+"','"+balance+"')");
int status = stmt.executeUpdate("insert into bank
values ('"+id+"','"+name+"','"+balance+"')");
System.out.println("Status:"+status);
if(status != 0){
con.commit();
ut.commit();
con.setAutoCommit(true);
System.out.println("Successfully commited");
}else{
ut.rollback();
System.out.println("Transaction
Rolledback");
}
if(con !=null){
con.close();
}
return true;
}
catch(Exception ee){
System.out.println("Server
Exception:"+ee.getMessage());
ee.printStackTrace();
return false;
}
}
public void ejbCreate(){}
public void ejbPostCreate(){}
public void ejbRemove(){}
public void ejbActivate(){}
public void ejbPassivate(){}
public void setSessionContext(SessionContext sc){}
}
Can any one tell me...Should I have to some other data source other than
oracle.jdbc.driver.OracleDriver .
As we have to use TXDataSource in Weblogic...do we have to use some other
datasource in JBoss..?
Yogaraj
-----Original Message-----
From: Kesav, Ramesh [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 24, 2002 2:31 PM
To: 'It, Cockpit (CAP, Contractor)'
Subject: RE: BMP Doubt!
Hi i think when you execute the statement the value is zero for success,
change the line of code
if(status != 0){
ut.commit();
System.out.println("Successfully commited");
}else{
ut.rollback();
System.out.println("Transaction Rolledback");
}
to
if(status == 0){
ut.commit();
System.out.println("Successfully commited");
}else{
ut.rollback();
System.out.println("Transaction Rolledback");
}
hope this will help you.
Regards
Ramesh Kesavanarayanan
Electronic Data Systems India pvt Ltd
* 91-44-254 9650 ext :2469
* [EMAIL PROTECTED]
"THIS E-MAIL MESSAGE ALONG WITH ANY ATTACHMENTS IS INTENDED ONLY FOR THE
ADDRESSEE and may contain confidential and privileged information.
If the reader of this message is not the intended recipient,
you are notified that any dissemination, distribution or copy of this
communication is strictly Prohibited.
If you have received this message by error, please notify us
immediately, return the original mail to the sender and delete the
message from your system."
===========================================================================
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".