Announcement Announcement Module
Collapse
No announcement yet.
Customer Specific DataSources Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Customer Specific DataSources

    Hi everyone,

    I'm currently porting an existing web application on Tomcat over to use the Spring framework. Everything seems pretty straight forward except for one snag I have run into regarding DataSources. I'm really not sure how to approach this using Spring and was hoping someone could help me out.

    The requirements of the app are as follows:

    1) When a user logs in they supply a customer specific account ID.
    2) This account ID is used throughout the code to look up a DataSource with the same JNDI name. This DataSource is then used when accessing the back end database.
    3) All of the datasources are defined in Tomcat's server.xml file, and thus new datasources can be added on the fly without having to bring the server down.

    I am trying to use the DAO framework for Spring but am running into several problems. My first is how I can have my DAO classes use the correct datasource based on the account ID passed to them. So far it seems that you pretty much have to hardcode in the appicationContext.xml file what datasource is being used by what DAO, if you want Spring to inject in the dependencies for you. I am also not sure how I can manage a transaction over multiple DAO calls when the TransactionManager looks like it needs a specific DataSource hardcoded into it as well.

    This is the first project I have undertaken with Spring and am still not familiar enough with it to figure out if I am missing something. Anyone have any suggestions?

    Thanks.
Working...
X