• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I need to store and use variable in EJB 2.0 like Application level variable in Servlets/Jsps

 
Greenhorn
Posts: 23
Firefox Browser Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using EJB 2.0 and i want to use variable like global variable, as we use application level or context level variables in Servles/jsp's like that i want to use variable in EJB 2.0. Please suggest is there any configuration in ejb's .xml file for this requirement.

Thanks
 
Ranch Hand
Posts: 430
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you want this? People usually say that global variable is not a good approach.

I think you can create a static variable in your bean or in any class. Like:

public class YourBean {

public static int myGlobalVariable;
}

Then you would use YourBean.myGlobalVariable;
 
kishukishor patil
Greenhorn
Posts: 23
Firefox Browser Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually i want to configure Connection Pool Name. And if i configure it as you suggest then it will need code changes if my connection pool change. On the other hand if i configure it in any .xml file like context parameter then i can change it any time only need to restart the server. This is the main reason, Please suggest me any good option. Or if there is way to use connection pool with ejb.


Thanks brother...
 
Ranch Hand
Posts: 608
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use an<env-entry> in the ejb-jar.xml....
 
Ranch Hand
Posts: 354
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

kishukishor patil wrote:Actually i want to configure Connection Pool Name. And if i configure it as you suggest then it will need code changes if my connection pool change. On the other hand if i configure it in any .xml file like context parameter then i can change it any time only need to restart the server. This is the main reason, Please suggest me any good option. Or if there is way to use connection pool with ejb.


Thanks brother...


Almost always you access a connection pool thru a datasource via jndi lookup. The datasource jndi name is specified in EJB XML files.
 
Politics is a circus designed to distract you from what is really going on. So is this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic