Hi All,

         I am using atleast 2 Entity Beans , each of which maintain a
Database connection. Now inside Stateful Session Bean I am accessing the
Database through the
 connection provided by the entity Beans.

         My question is suppose 2 clients are accessing the Session
Bean, and if the Session Bean created by client1 is accessing Entity Bean
1 , how can I route my 2nd
 Session Bean created by client2 to the "Entity Bean2"?

       All the 2 Entity Beans are created during client1 calling the
ejbHome.create() of Session Bean1.

 The attributes of " Session Bean" class are :
         EntityBeanHome th;
 EntityBean items[] = new EntityBean[2];
 protected transient Context ctx;


 Is there any method which can tell me whether the particular Entity Bean
 is free or in use?


 public void ejbCreate()
 {

   try
   {
       ctx = new InitialContext();

       try
       {
         th = (EntityBeanHome) ctx.lookup("EntityBeanEJB");

         System.out.println("\n After JNDI lookup... " );


         for (int i = 0; i < 2; i++)
         {
             System.out.println("\n Inside for loop... " );

             try
             {
               System.out.println("\n Inside try block... " );

               items[i] = th.findByPrimaryKey(new EntityBeanPK(i));
}
             catch (FinderException e)
             {
         try
               {
                   System.out.println("\n Inside try block of catch...
" );

             items[i] = th.create(i);
           System.out.println("Creating... " + i);
         }
               catch (CreateException ee)
               {
     System.out.println("Unable to create transcript");
System.out.println(ee);
                 ee.printStackTrace();
         }
             }
         } // end of for loop
       } // end of try
       catch (NamingException e)
       {
           System.out.println(e.getMessage());
           System.out.println("Explanation " + e.getExplanation());
e.printStackTrace();
       }
       catch (Exception e)
       {
           System.out.println(e);
           e.printStackTrace();
       }


   Please Help ..

 Thanx in advance..

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to