Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to insert data in multiple database.

 
raj malhotra
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
According to the usecase whenever update happen it should update all the dbs in remote place.which are in different geographical locations.Whatever i understood about distributed transaction is:
1.I can configure the Datasource in application server which support global transaction.
2.In my code i need to get the datasource.
3.get a connection.
4.begin transaction.
5.update db
6.end transaction.
But my doubt is i am having just one connection which i got for one db.so i can update that db.Can i use this connection to update other dbs?Is it a global connection.
Can anyone explain me step 5 in details to update multiple db.

Thanks
Raj
 
Raf Szczypiorski
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A DataSource is an abstraction of a physical database server and schema / user. It can only connect to a single database. To update 2 databases, you need two datasources.
 
raj malhotra
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then How should i maintain a distributed transaction??
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You do not have to do anything "special" to handle a distributed transaction.
Conceptually, in between the begin and end of a transaction whatever you do is inside the ambit of that transaction. Whether you update 2 databases, 1 Database and 1 JMS queue or 100 databases, it does not really matter.
All it matters is that the driver must support distributed transactions i.e. it must be an XA driver.

In case you are using weblogic, this article will give you a good idea.
 
raj malhotra
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much Nitesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic