2

We are using a spring MVC web application with a single data source (MySQL). We have a new requirement now:

We would like that some of our clients will use as their data source - machine#1's MySQL db.

And other clients should use as their data source - machine#2's MySQL db.

both of these data sources are identical in structure, only with different data.

This 2 different machines contain databases of two different customers that do not want to share the same database for obvious reasons.

Is that possible to do with minimal change of our code base?

1 Answer 1

3

You can consider AbstractRoutingDataSource

The general idea is that a routing DataSource acts as an intermediary - while the ‘real’ DataSource can be determined dynamically at runtime based upon a lookup key.

https://spring.io/blog/2007/01/23/dynamic-datasource-routing/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.