• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to connect different datasources using multiple datasource using ENC

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to connect different datasources using multiple datasource using ENC in jboss?

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();
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check the DTD:

<!ELEMENT session (description?, display-name?, small-icon?,
large-icon?, ejb-name, home?, remote?, local-home?, local?,
ejb-class, session-type, transaction-type, env-entry*, ejb-ref*,
ejb-local-ref*, security-role-ref*, security-identity?, resource-ref*,
resource-env-ref*)>


As the resource-ref element can occur zero or more times, you should declare as many as needed.
 
maha laxmi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Roger Chung-Wee:
Check the DTD:

As the resource-ref element can occur zero or more times, you should declare as many as needed.



THANKS it worked
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic