2 Replies Latest reply on Jun 10, 2004 9:23 AM by ignacio cuesta

    Changing a Datasource at runtime

    ignacio cuesta Newbie

      Consider a hypothetical application that needs to be deployed on a single app server and has to service mulitple clients. Consider that there is a database per client. Thus n databases for n clients. However, all of these database have the same structure, and only the content varies.

      Now to the problem:
      Can I use CMP's in this context where I need to connect to different databases(with absolutely identical structure)
      for each client. Different databases mean different Datasources, hence how do I uniquely associate a CMP Entity Bean with a single table for a particular datasource. Also, we do not want a different entity bean set for each database!

        • 1. Re: Changing a Datasource at runtime
          John Baker Newbie

          I have the same requirement/problem at the moment. I cannot specify the datasource in the deployment descriptor of the EJBs because it varies depending on the account being operated on. Accounts are added/removed occasionally and to redeploy the app every time is just crazy. A number of users have access to the each account (DB).

          In my current experiment I have created a data source factory which creates custom datasources which maintain their own pool but this seems to be creating some strange problems of it own and seems to confuse jboss transaction manager. I am about to try another approach and will post here if any more successful..

          Please if anyone else has already done this let me know.

          I need to be able to create/destroy/access new datasources on the fly.

          • 2. Re: Changing a Datasource at runtime
            ignacio cuesta Newbie

            I read a note from Alexey Loubyansky on http://www.junlu.com/msg/36487.html but I can't get some other examples.
            Could you give me an examples of your DataSource Factory ?
            Thanks in advance!!!