Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

WHY I can't see transaction for jdbc api

 
liang sun
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
try
{
.......
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
thanks

 
Stanley Tan
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic