4 Replies Latest reply on Mar 6, 2002 7:55 PM by davidjencks

    Configuration for accessing two Oracle databases

    colm_daly

      Hi,

      I'm new to jBoss so apologies in advance if there is an obvious error below.

      I'm trying to configure jBoss 2.2.2 to access two Oracle databases. It works fine with just one database, when I add the second it appears to work fine at server startup but the code cannot find the resource.

      I have modified jboss.jcml as follows:

      <!-- JDBC -->

      oracle.jdbc.driver.OracleDriver



      testdb1ds
      jdbc:oracle:thin:@localhost:1521:MYDB1
      xxxx
      xxxx


      <!-- I added this new db -->


      testdb2ds
      jdbc:oracle:thin:@localhost:1521:MYDB2
      xxxx
      xxxx


      (User/passwords commented out)

      In the log for jboss I get:
      [JDBCDataSource] Starting
      [JDBCDataSource] JDBC Connection pool testdb1ds bound to java:/testdb1ds
      [JDBCDataSource] Started
      [JDBCDataSource] Starting
      [JDBCDataSource] JDBC Connection pool testdb2ds bound to java:/testdb2ds
      [JDBCDataSource] Started

      In the app log, I get:
      java.lang.RuntimeException: Resource [testdb2ds] not found, returning NULL

      Thanks,
      Colm

        • 1. Re: Configuration for accessing two Oracle databases
          earlgrey


          Colm,

          I currently use multiple dbs/datasources and I do use similar configuration in jboss.jcml.

          You might not have declared your datasources in the entities jaws.xml (instead the default DS is used):


          java:/MYDB1
          <type-mapping>Oracle8</type-mapping>
          ...


          Lars

          • 2. Re: Configuration for accessing two Oracle databases
            colm_daly

            Lars,
            They were not defined in jaws.xml. However it still does not work. Maybe I am doing it wrong in jaws.xml. I now have:



            <!-- Original
            java:/DefaultDS
            <type-mapping>Hypersonic SQL</type-mapping>
            false
            -->
            java:/MYDB1
            <type-mapping>Oracle8</type-mapping>
            java:/MYDB2
            <type-mapping>Oracle8</type-mapping>

            <default-entity>
            <create-table>true</create-table>
            <remove-table>false</remove-table>
            <tuned-updates>false</tuned-updates>
            <read-only>false</read-only>
            <time-out>300</time-out>
            <select-for-update>false</select-for-update>
            </default-entity>

            <type-mappings>
            .... as before

            (I also tried testdb1ds and testdb2ds instead of MYDB1 and MYDB2 above)

            Colm

            • 3. Re: Configuration for accessing two Oracle databases
              earlgrey

              Hmm,
              it looks like you use multiple DS in a single ejb app?
              I have several apps, however, each one uses a single (different) DS (that is declared in jaws.xml, NOT standardjaws.xml).

              I have no experience with declaring multiple datasources in a single application. I do not think it will work this way:

              java:/MYDB1
              <type-mapping>Oracle8</type-mapping>
              java:/MYDB2
              <type-mapping>Oracle8</type-mapping>


              Anyone else?

              Lars

              • 4. Re: Configuration for accessing two Oracle databases
                davidjencks

                I'm about 80% sure you can't do this in 2.2.2. Theres a good chance you can in 2.4.4, although you would have to declare the datasource with the ejb you want it to use. It is definitely possible with jboss 3 cmp2 -- see jbosscmp-jdbc.dtd for how.