1 Reply Latest reply on Nov 22, 2006 7:00 AM by Subramaniam Venkatachalam

    How to dynamically configure a datasource

    Aldo Newbie

      Hi, I have a web application requiring to connect to one of several SQL Server databases. They are all identical in structure; what changes is the IP address, user and password. So far I had configured datasources as -ds.xml files in the deploy directory. But in this case I don't know the connection parameters in advance: they are discovered at runtime depending on the user who logs in. Is there any way in JBoss to dynamically setup a javax.sql.Datasource object and do the JNDI binding at runtime? As additional information, I'm using Spring + Hibernate. Thanks!!!

        • 1. Re: How to dynamically configure a datasource
          Subramaniam Venkatachalam Newbie


          Any file which you put in the deploy directory will be deployed by JBoss.
          I am also using a similar kind of design where i build a dynamic datasource.
          For the next request which comes in check whether the old datasource string and the new datasource are not equal then if they are not equal then i deploy the new datasource.

          And i also sleep if i deploy the datasource for sometime . So that the new datasource is deployed. But i never change the jndi name of the datasource.

          I hope this must help you.

          Take Care,