• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is the best way for data source lookup from session bean??  RSS feed

 
Anjali Sen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
What is the best way for data source lookup from
session been when both (ejb contaioner and data
source) exist in same websphere 3.5 app. server.
Is it a good idea to store the data source instance in static field in a bean and access same using sataic methods. Please advise.
url or sample code pls
 
Michael Arndt
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An ejb must not use static variables.
Better perform a lookup on a managed resource for which you added a resource-ref entry in the deployment descriptor.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That would be hunky-dory IF he was working in an EJB 1.1 or EJB 2.0 compliant container -- but WAS 3.5 is only EJB 1.0 compliant. (He's two versions back from the current version).
Actually, storing a DataSource in a singleton (so long as it's a special singleton helper class and you DON'T try to put a static variable in the EJB like Michael said) would work fine.
Kyle
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!