This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JBoss/WildFly and the fly likes  how to connect multiple datasource using ENC in jboss Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark " how to connect multiple datasource using ENC in jboss" Watch " how to connect multiple datasource using ENC in jboss" New topic
Author

how to connect multiple datasource using ENC in jboss

maha laxmi
Ranch Hand

Joined: Sep 23, 2005
Posts: 68
oracle-ds.xml
**************
<?xml version="1.0" encoding="UTF-8"?>



<local-tx-datasource>
<jndi-name>oraclePool</jndi-name>
<connection-url>jdbc racle:thin:@**.**.**.* ortno:***</connection-url>
<driver-class>drivername</driver-class>
<user-name>xyz</user-name>
xy
</local-tx-datasource>


<local-tx-datasource>
<jndi-name>reportPool</jndi-name>
<connection-url>jdbc racle:thin:@***.**.**.** ortno:**</connection-url>
<driver-class>drivername</driver-class>
<user-name>abc</user-name>
ab
</local-tx-datasource>




ejb-jar.xml
***************
<ejb-jar>

No Description
<display-name>EmpSessionBean</display-name>
<ejb-name>EmpSessionBean</ejb-name>
com.blah.blah.EmpSessionBeanHome
com.blah.blah.EmpSession
<ejb-class>com.blah.blah.EmpSessionBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>

************** noramally we write res-ref-name for every beans but in this case if i connect multiple datasource which res-ref-name should i write Is it jdbc/DB or jdbc/reportDB ****************
<resource-ref>
No Description
<res-ref-name>jdbc/DB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>


</ejb-jar>

jboss.xml
*************



<ejb-name>EmpSessionBean</ejb-name>
<jndi-name>EmpSessionBean</jndi-name>

************** noramally we write res-ref-name for every beans but in this case if i connect multiple datasource which res-ref-name should i write, Is it jdbc/DB or jdbc/reportDB ****************

<res-ref-name>jdbc/DB</res-ref-name>
<resource-name>oraclePool</resource-name>

<resource-managers>
<resource-manager res-class="">
<res-name>jdbc/reportDB</res-name>
<res-jndi-name>java:/reportPool</res-jndi-name>
</resource-manager>

<resource-manager res-class="">
<res-name>jdbc/DB</res-name>
<res-jndi-name>java:/oraclePool</res-jndi-name>
</resource-manager>
</resource-managers>



from session bean i am trying to look up multiple datasources like this

dataSource = (DataSource)ictx.lookup("java:comp/env/jdbc/DB");--------------- xyz user should be connected
Connection con= dataSource.getConnection();

dataSource = (DataSource)ictx.lookup("java:comp/env/jdbc/reportDB");--------------- abc user should be connected
Connection con= dataSource.getConnection();
[ January 24, 2006: Message edited by: maha laxmi maha laxmi ]
Wiley Snyder
Greenhorn

Joined: Oct 26, 2005
Posts: 23
to look up multiple datasources using jndi your going to have to put them in your [[[[[[[[C:\jboss-XXX\server\default\deploy\XXXXwhateverdatabase-ds.xml

file.

i.e....

one of my development environments on Windows ...



 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to connect multiple datasource using ENC in jboss
 
Similar Threads
how to connect different datasources using multiple datasource using ENC
error in deploying ejb2.0 bmp in jboss 4.5
error in deploying ejb2.0 bmp in jboss4.5
J2EE Development with JBoss3.2
Error with creation of data source