how can I save data in 2 different database like Oracle and Mysql simultaneously. I am using Spring 2.5 and Hibernate for my project.
Please help on this.
Thanks in advance
You will have to have two different dataSources. One for each database, and with Hibernate you will need two SessionFactory(s) one for each database, or 2 EntityManagerFactory(s) if you are using Hibernate just as your implementation of JPA. And unless you use JTA, then you will also need two TransactionManagers.
This will be true whether you are using Spring or not. It is about the database stuff.
Thanks for the response.
Now I am able to save data in 2 database(Oracle and MySQL) simultaneously.
I have another concerned here.
If I have only one database connection active and another database is stopped/disconnected, then I am getting error.
What i will set in my config file to fix this issue.
How I will select the active database through my config file???
But remember that you will have to configure distrubuted transaction support in first case.
Be careful. While this is important, it adds confusion to the original poster.
So I am confused, if you want to save to one but not the other if it is down. Are you trying to do this as a failover or backup design? If not, then I would probably think that you wouldn't want a partial commit, you would want it to fail if one of them is down.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: How to save data in 2 db simultaneously by using Spring Hibernate