5 Replies Latest reply on Jun 20, 2003 3:30 AM by Bernd Zeitler

    Configuring multiple datasource

    seemanto Newbie

      Hi
      can any one tell me how do i configure multiple datasource for my application.It needs to access different databases which is decided at runtime.

      Do i need to define a separate MBEAN for each datasource or how to do it?

        • 1. Re: Configuring multiple datasource
          Bernd Zeitler Expert

          You have to deploy a *-ds.xml file which is holding the datasource configuration. There are example files in the docs/examples/jca directory of jboss.
          You can use one *-ds.xml for all your datasources or several files.
          The datasources are accessible via JNDI then (java: namespace).

          Greetings,
          Frito

          • 2. Re: Configuring multiple datasource
            seemanto Newbie

            Well i am not able to find *-ds.xml files but i do have
            *-service.xml files for almost all dbms. Since i am using DB2 i have directly used db2-service.xml and put it in deploy directory along with the jars etc. Every thing is working fine for a single datasource but how do i configure multiple jndi bindings that point to different datasources which have different database schemas. Do i have to define a different MBEAN (i tried doing that i gave error while booting). or do i have to put the definition in a seperate xml file itself.

            • 3. Re: Configuring multiple datasource
              Bernd Zeitler Expert

              Well, the *-service.xml is for older versions, but for you it is just the same. You can use several *-service.xml files or you can have several configurations in one file, since every configuration has its own JNDI name.

              Greetings,
              Frito

              • 4. Re: Configuring multiple datasource
                seemanto Newbie

                Hi dude
                Can you just tell me how to define multiple datasource in a single *-service.xml. Creating multiple files looks cubersome as i have many connectionpool to maintain.

                The following is the code segment from *-service.xml where i define the connection pool


                <depends optional-attribute-name="ManagedConnectionFactoryName">
                <!--embedded mbean-->


                DB2DS


                <config-property name="ConnectionURL" type="java.lang.String">jdbc:db2://192.168.1.3/sample</config-property>
                <config-property name="DriverClass" type="java.lang.String">COM.ibm.db2.jdbc.app.DB2Driver</config-property>
                <!--set these only if you want only default logins, not through JAAS -->
                <config-property name="UserName" type="java.lang.String">testadm</config-property>
                <config-property name="Password" type="java.lang.String">psyche32</config-property>



                <!--Below here are advanced properties -->
                <!--hack-->
                <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper

                • 5. Re: Configuring multiple datasource
                  Bernd Zeitler Expert

                  A datasource is described as mbean. This description includes things like class name, jndi name, dependencies and so on. You can configure several mbeans with one service xml. Read the dtd for further information.

                  Greetings,
                  Frito