0

Problem description

I have 6 databases from 6 different machines, and having one cloud server. It will decided at the time of user login that which database is going to use in application.

I am able to connect with single database. But I have no idea to handle dynamic names of databases.

Update:

I am able to change databases dynamically, but one problem is going on. There are some stored procedures in only one database that is common (placed at cloud server), (I have restriction where I can't add stored procedures to all databases), so I am not able to call stored procedures for any other databases. How can I call?

Please give me some ideas.

2
  • 1
    What is the decision criteria of selecting different databases? Commented May 25, 2012 at 14:50
  • Your update sounds like en entirely different problem than before. If you have solved your initial problem, please accept an answer or post your solution. You should then create a new question for your new problem, or try searching SO for an existing question to see if there are any helpful answers. Commented May 30, 2012 at 16:24

2 Answers 2

3

In Spring there is a class called AbstractRoutingDataSource which will suites for your requirement, Go through the documentation you will find some help on how to implement a concrete class of this, You need to change(or add) some part of you existing code in order to configure the dynamic Data source. This blog from spring source is explaining this in action.

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

Comments

1

This Java Ranch Forum Topic explains how to do it. It shows you how to change username/password at runtime but I imagine that it would be the same pattern to change parts of the connection string or anything else.

http://www.coderanch.com/t/489984/ORM/java/modify-hibernate-cfg-xml-at

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.