permaculture playing cards
The moose likes JDBC and Relational Databases and the fly likes WHY I can't see transaction for jdbc api Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "WHY I can Watch "WHY I can New topic

WHY I can't see transaction for jdbc api

liang sun
Ranch Hand

Joined: May 12, 2001
Posts: 51
in ejb's method, i have a program using JDBC API.
ejb'method's transaction attribute is required as default.
It is container managing transaction bean.
Statement s=con.createStatement()
s.execUpdate("sql1 "); //sql1 is correct "insert into.."
s.execUpdate("sql2"); //sql2 is false "insert into."
catch(Exception e)
throw new EJBException();
when executing, client program received ejbException from ejb.
but "sql1"'s executing result reflect to Database though "sql2"
execute failure��
why contain's transaction don't work?(in session bean and entity bean'S attempting result is same)
pls give me some advice or material

Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
I am not sure what exactly you are asking. But from what I can gather, you have to set auto commit to false. That way you can execute several SQL statements and latter if something goes wrong rollback the statements as if nothing had happened.
I agree. Here's the link:
subject: WHY I can't see transaction for jdbc api
It's not a secret anymore!