posted 21 years ago
I use weblogic6.1sp2 + jdk131
A stateless session bean must do 2 things:
insert a record to A table and delete another record in A table
This bean has the same structure as the example in j2eetutorial/examples/src/ejb/teller
I use TxDataSource in weblogic
If delete fail, the roll back is run,but in database,
the insert record is STILL in A table.
More:
I close the connection autocommit,but find no records can be inserted into the table,why?
Code For begin,commit and rollback
UserTransaction ut = null;
try{
ut = sessionContext.getUserTransaction();
ut.begin();
//test code
ut.commit();
}catch(Exception e){
try {
ut.rollback();
}
catch (SystemException se) {
}
}
Code for connection:
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup(dbName);
con = ds.getConnection();
con.setAutoCommit(false);