2 Replies Latest reply on Mar 11, 2009 6:22 PM by bluegirl125

    pulling connection url out of Datasource files

      Hi,

      Currently jboss 4.2.2 is set up to connect to the oracle db using xx-ds.xml files with the following format:

      <datasources>
       <local-tx-datasource>
       <jndi-name>TestDS</jndi-name>
       <connection-url>jdbc:oracle:thin:@host:1521:SID</connection-url>
       <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
       <user-name>xxxx</user-name>
       < password>yyyy</ password>
       <prepared-statement-cache-size>32</prepared-statement-cache-size>
       <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
       <!-- Checks the Oracle error codes and messages for fatal errors --> <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
      
       <!-- sql to call when connection is created-->
       <new-connection-sql>SELECT 1 FROM DUAL</new-connection-sql>
       <!-- sql to call on an existing pooled connection when it is obtained from pool -->
       <check-valid-connection-sql>SELECT 1 FROM DUAL</check-valid-connection-sql>
       <metadata>
       <type-mapping>Oracle10g</type-mapping>
       </metadata>
       </local-tx-datasource>
      </datasources>

      There is one file defined for each datasource, and we have ~10 such files. Now we are migrating over to Oracle RAC, so the connection url requires changing. However, if we add more hosts to later on, I do not want to have to change the connection URL for each datasource file again. Is it possible to pull out the connection URL and place it somewhere so it gets defined only once, and refer to that in all the xx-ds.xml files?

      I am thinking no, but :) just want to see if I am missing any jboss set up options here...

      Thanks very much!


        • 1. Re: pulling connection url out of Datasource files
          peterj

          Are you saying that all of the files have the same URL? If so, you are in luck! You can replace the URL with a system property reference, for example:

          <connection-url>${your.oracle.rac.url}</connection-url>


          Then set the your.oracle.rac.url system property in the run script by adding "-Dyour.oracle.rac.url=jdbc:oracle:thin:@host:1521:SID" (or whatever the actual URL is) to JAVA_OPTS.

          And you can even provide a default value, just in case you run the app server without specifying the system property:

          <connection-url>${your.oracle.rac.url:jdbc:oracle:thin:@host:1521:SID}</connection-url>



          • 2. Re: pulling connection url out of Datasource files

            Hi Peter!

            That solves it. Thanks for the help!