• Post Reply Bookmark Topic Watch Topic
  • New Topic

ejbLoad() problem  RSS feed

 
jeff zhang
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a BME bean which is supposed to provide services to
outside calls. The bean needs to access two different database
servers for some of its method invocations. I tried to use
a flag value inside ejbLoad() to determine which server the persistence fields should come from. But, I did not get what I
expect due to wrong flag value. Can anybody help me?
Thanks,
Jeff
The following is a pieces of codes:
public void ejbLoad()
{
BeanPK (BeanPK) context.getPrimaryKey();
Connection con = null;
if (flag = 1)
{
con=this.getConnectionA();
.....
}
else if (flag = 2)
{
con=this.getConnectionB();
.....
}
....
}
The flag is an instance variable and was set in methods like
findByPrimaryKey(), findFromdbA(), and findFromdbB(). If caller
invokes findFromdbA() and findFromdbB() alternatively, the wrong
flag value will be seen.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!