I have made a servlet calling some java bean (not EJB) which process some database queries, insert and update. However, I would like them to be in an atomic transaction.
I have tried to use setautocommit which fails because I use the connection pool of JBoss. So I think maybe I need to use JTA inside the servlet. So I try this:
Properties prop = new Properties();
InitialContext ctx = new InitialContext(prop);
utx = (UserTransaction) ctx.lookup("UserTransaction");
where myObj.save() contains some coding to insert, update and select the database.
However, it seems this does not work coz I deliberately return error in one of the update statement that I found the db is not rollback.
Since I am new to JTA and also JBoss, I do not know whether my concept is correct or not. Or is there any website for me to get some sample code and know more about these?