Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
    Bookmark Topic Watch Topic
  • New Topic

How to handle multiple database connections with spring?

 
Don boscoo
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi All,

How to setup multiple database connections in spring simultaneously? How to configure it in app-config.xml ? Can someone tell me the best practise to do it?

Thanks.
 
pete reisinger
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Report post to moderator
check c3p0 - http://www.mchange.com/projects/c3p0/index.html
you'll use it as your dataSource param for session factory
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
I actually don't think the poster meant a Connection Pool, but more that they have more than one database that they need to talk with.

Each Database will needs its own DataSource, and Data Access Technology bean class needed (ie SessionFactory, JdbcTemplate, EntityManagerFactory)

If you do not have a JTA Transaction manager that does two phase XA commits, then you will need a transaction manager for each database too.

Mark
 
Ramanuj Dev
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please let me know the solutions to do transaction in multiple database simultaneously.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
Ramanuj Dev wrote:Please let me know the solutions to do transaction in multiple database simultaneously.


Please don't duplicate post. This is an older thread and therefore probably won't get a new asnwer to it, so I am going to close it so it doesn't get resurrected again.

Thanks

Mark
 
    Bookmark Topic Watch Topic
  • New Topic