4 Replies Latest reply on May 21, 2005 3:56 PM by morenito9000

    Two DataSources (correct version)

    morenito9000

      Hi all,
      I'm confused about how I can use two DataSources in my application.

      I access the first DataSource (a PostgresDB) using Entity Beans
      (for db changes) and Stateless Session Bean + DAO (for db readings).

      In /conf/standardjbosscmp-jdbc.xml file I put
      configurations of my PostgresDB (inside < defaults > section).

      In jboss.xml file I declare that my beans uses PostgresDB
      (inside <resource-ref> section).

      The question is:
      If I need (I have) to write a NEW Stateless Session Bean that access
      an OracleDB DataSource can I add another < defaults >
      section inside standardjbosscmp-jdbc.xml file (and refer to this NEW
      section in jboss.xml file) ?

      Many thanks in advance for any help
      Moreno

        • 1. Re: Two DataSources (correct version)
          raja05

          You can create any number of datasources. Dont modify the standardjbosscmp-jdbc.xml. Thats the default configuration and you shouldnt be modifying it.
          So to do what you want, you can add any xml file that ends with
          -ds.xml . For examples, look under docs/examples/jca in ur jboss distribution. Or Look at the hsqldb-ds.xml in ur deploy directory.

          • 2. Re: Two DataSources (correct version)
            morenito9000

            >You can create any number of datasources. Dont modify the standardjbosscmp-jdbc.xml. Thats the default configuration and you shouldnt be modifying it.

            OK, I emptied < default > section in standardjbosscmp-jdbc.xml
            (now it's in its "original version") and I put the section
            in my jbosscmp-jdbc.xml file.

            >So to do what you want, you can add any xml file that ends with
            -ds.xml . For examples, look under docs/examples/jca in ur jboss distribution. Or Look at the hsqldb-ds.xml in ur deploy directory.

            I need only to put an oracle-ds.xml file inside deploy directory ?

            For postgres I put postgres-ds.xml file inside deploy directory
            but I also had to specify in < default > section of jbosscmp-jdbc.xml
            file that my EJB's used this DataSource.
            I think that I need to do the two steps for Oracle too.

            Am I wrong ?

            Thanks
            Moreno





            • 3. Re: Two DataSources (correct version)
              raja05

              nope u dont have to. If you just want ur datasource defined for EJBs or whatever, just drop ur oracle-ds.xml in the deploy directory and that will bind the Datasource to a JNDI name. I hope thats what you want

              • 4. Re: Two DataSources (correct version)
                morenito9000

                Thank you Raja05,
                I drop in deploy directory an oracle-ds.xml file
                and I created a SLSB that connects to this OracleDB :-)

                Hi,
                Moreno