Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

doubt about ejbCreate()

 
Anand Wadhwani
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

Got a doubt about a line in HF-EJB book, pg #196

It says: You can't make a JDBC call on connection reference. You can use your connection in ejbCreate()

I checked both confirmed / unconfirmed errata as well, didn't get anything.

Or may be I am confused and not interpretting things correctly. If I can get connection objectinside ejbCreate(), why can't I use it for a JDBC call? It all makes sense. Why can't I initialize some instance variable from database inside ejbCreate() and use it repeatly in different business methods of a stateful bean?

TIA for all the help!
 
Micheal Jacob
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

EJB Spec. 91

"Accessing resource managers and enterprise beans are not allowed in the session bean methods for which the container does not have a meaningful transaction context or client security context."

In stateless session beans, Bean provider doesn't have any control on ejbCreate method. (i.e) Independent of client.

Micheal.
 
Micheal Jacob
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Above para from Spec applicable for stateful bean also....

Micheal.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!