本文发表在 rolia.net 枫下论坛In a distributed J2EE application we are developing, a stateless session bean is used to query and update MS Acess database in 3 steps: (1) Get the maximum ID from the first table where ID is the primary key. (2) Insert a row into the first table using the ID+1 as the primary key . (3) Insert a row into another two tables using ID+1 as foreign key.
We use JBoss 3.0 as application server. Because this is distributed application, there are more than one session bean instances running at the same time in the EJB container. When one EJB instance is running at the 2nd step (not finishing the inserting), another EJB instance will be running at the 1st step. Therefore, the 2nd EJB instance will get the same ID and thus causes SQL exceptions. How to deal with this?
Another issue is when one EJB instance is running at the 2nd or 3rd step, other EJB instances that try to update MS Access table will also cause a SQL exception. This is because the database cannot be updated by two EJB at the same time. How to deal with this?
Because MS access does not support transaction, we cannot use SQL transactions. How to make Step 1 to 3 completed by one EJB instance before another EJB instance executes step 1?
I cannot input Chinese. Your response is highly appreciated.
Thanks!!!更多精彩文章及讨论,请光临枫下论坛 rolia.net
We use JBoss 3.0 as application server. Because this is distributed application, there are more than one session bean instances running at the same time in the EJB container. When one EJB instance is running at the 2nd step (not finishing the inserting), another EJB instance will be running at the 1st step. Therefore, the 2nd EJB instance will get the same ID and thus causes SQL exceptions. How to deal with this?
Another issue is when one EJB instance is running at the 2nd or 3rd step, other EJB instances that try to update MS Access table will also cause a SQL exception. This is because the database cannot be updated by two EJB at the same time. How to deal with this?
Because MS access does not support transaction, we cannot use SQL transactions. How to make Step 1 to 3 completed by one EJB instance before another EJB instance executes step 1?
I cannot input Chinese. Your response is highly appreciated.
Thanks!!!更多精彩文章及讨论,请光临枫下论坛 rolia.net