• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

enthuware mock exam question 11 from Test 1

 
Ranch Hand
Posts: 644
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the statements are true regarding the following enterprise bean code snippet appearing in a business method?


Code

...
Context initContext = new InitialContext();

DataSource ds1 = (DataSource)initContext.lookup("java:comp/env/db1");
Connection con1 = ds1.getConnection();
DataSource ds2 = (DataSource)initContext.lookup("java:comp/env/db2");
Connection con2 = ds2.getConnection();

UserTransaction tx = ejbContext.getUserTransaction();
tx.begin();
//use the connection to update database 1.
//use the connection to update database 2.
tx.commit();
con1.close();
con2.close();
...


Select 1 correct option.

This code is invalid in all kinds of EJBs.

This code is invalid in Session beans.

This code is invalid in Entity beans.

This code is invalid in Message driven beans.

This code is invalid in Stateful Session beans.

The correct answer is : This code is invalid in Entity beans.

Can someone please explain why is it so?? they have not provided the explanation.

thanks,
trupti
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An Entity Bean can only use Container Managed Transaction. The code clearly try to use BMT.
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition. for EJB 1.x, EntityBean can use BMT, however, for EJB 2.0, BMT is prohibit for EntityBean.

Nick
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Yi Fang:
An Entity Bean can only use Container Managed Transaction. The code clearly try to use BMT.



Welcome to the Ranch, Yi Fang!!!

You did a nice explanation to nigam as well....
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't get confused between CMP and CMT Entity beans are always CMT whether they are BMP or CMP
 
grapes are vegan food pellets. Eat this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic