0 Replies Latest reply on May 2, 2013 12:03 PM by baddeley84

    Datasource config depending on environment

    baddeley84

      Hi,

       

      I want to connect to 2 datasources from my application, this is fine, however the second datasource is on a different machine in production, and on the same machine in development, what is the best way to address this, is it possible to use an environment variable to define the connection-url?

       

      Currently the configuration is as follows

       

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE datasources PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"

                                   "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">

      <datasources>

      <local-tx-datasource>

        <jndi-name>processorDatasource</jndi-name>

        <connection-url>jdbc:postgresql://127.0.0.1:5432/AppProcessor</connection-url>

        <driver-class>org.postgresql.Driver</driver-class>

        <user-name>jboss</user-name>

        <password>****</password>

      </local-tx-datasource>

      <local-tx-datasource>

        <jndi-name>viewerDatasource</jndi-name>

        <connection-url>jdbc:postgresql://127.0.0.1:5432/AppViewer</connection-url>

        <driver-class>org.postgresql.Driver</driver-class>

        <user-name>jboss</user-name>

        <password>****</password>

      </local-tx-datasource>

      </datasources>

       

      This works in development where both databases are on my local machine, but in production the AppViewer database is on a different machine (same LAN)

       

      I couldnt see any similar examples can anyone help?

       

      Thanks