• Post Reply Bookmark Topic Watch Topic
  • New Topic

ejb 3.0 and multiple databases  RSS feed

 
n kallamvalli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to EJB 3.0.I have one db2 database and 3 as400 databases. when I create a new record in one of the db2 table(db2 database),I have to create the same record in 3 as400 table(3 seperate as400 databases).This has to happen in one transaction.whenever something any of the insert fails I need to rollback everything. I use ejb 3.0 session bean(business layer) and JPA(OR mapping).

I created 4 ejb projects.I created 4 seperate persistence units for each databases.I am planning to call my main method from from first EJB project Session bean and within that I planning to use 4 methods to insert into didfferent databses.

EjbProject1
sessinbean
main mehtod

(
insert mthod1 ===> to insert DB2 table
insert method2 ===> call remotely EjbProject2 session bean method to insert to As400 database1
insert method3 ===> call remotely EjbProject3 session bean method to insert to As400 database3
insert method4 ===> call remotely EjbProject4 session bean method to insert to As400 database4 }
all these should be part of one transation.


I do not know whether it is going to work or not? any body has any idea? Anybody has example that deals with multiple databases or how distributed transaction work with multiple databsaes in EJB 3.0?

Please help
Many thanks
 
Mike Keith
author
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That should work fine as long as a) the methods execute within the context of the same JTA transaction and b) the drivers fully support XA
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!