Hi again Adrian,

That's a slightly different question than I thought you were asking. If I understand 
correctly, you want to be able to connect to different databases with the same 
application without changing the source code. You may not realize it, but your 
datasource is not "cardcoded". You can put any connection URL in the datasource xml 
file. For example, my application MYAPP can connect to Postgresql or Oracle, depending 
on which of two versions of the myapp-ds.xml I deploy. The source code references 
java:/MYAPPDS. myapp-ds.xml looks like this:
 

  <local-tx-datasource>
    <jndi-name>MYAPPDS</jndi-name>
    <connection-url>jdbc:postgresql:DBNAME</connection-url>
    <driver-class>org.postgresql.Driver</driver-class>
    <user-name>USERNAME</user-name>
    < password>PASSWORD</ password>
  </local-tx-datasource>


or like this:


  <local-tx-datasource>
    <jndi-name>MYAPPDS</jndi-name>
    <connection-url>jdbc:oracle:[EMAIL PROTECTED]:1521:ORCL</connection-url>
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <user-name>USERNAME</user-name>
    < password>PASSWORD</ password>
  </local-tx-datasource>


WIthin the ejb source code, it is sometimes necessary to detect which of the two 
databases I am actually connected to. (For example, I might want to use a different 
expression for todays date, dependng on whether its Oracle or Postgresql.) I use the 
example I gave earlier to do this. I hope I answered the question you asked.

Cheers.
Larry

<a 
href="http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3825284#3825284";>View 
the original post</a>

<a 
href="http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3825284>Reply 
to the post</a>


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to