• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding two database access.

 
sivakumar ganti
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Currently in my project i have CMP beans which have all access to the databse at a specified location.But the problem is that one module require to
access data from a different DB.Can i use CMP to access that if so how should i specify that CMP alone to access the other database.One option i am confident of is that i can model it as BMP and make a connection and handle transaction as well with user transaction.

gusy please suggest some ideas to access it with CMP.

thanks
siva.
 
VP Jain
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What is the EJB container u are using?.Please be specific on the environment.

Coz....it depends on the container.

-Regards
Parsuvanath.
 
sivakumar ganti
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using JBOSS 3.2.3 .

thankx
siva
 
Nitin Singh
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about deploying the same EJBs with two different databases, your code doesn't change you just need to deploy the same EJB(s) pointing to different DB.
 
sivakumar ganti
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,
Guys i think my previous question is confusing.I am making my question as simple as possible.?? please answer

I just need to find how to configure a CMP bean to point to one database and another CMP bean with in the same applicaiton to another database.

In conf directory i have this config
standardjbosscmp-jdbc.xml
<defaults>
<datasource>java:/MySQLDS</datasource>
<datasource-mapping>mySQL</datasource-mapping>
--
--
</defaults>

in deploy directory i have
mysql-ds.xml as
<local-tx-datasource>
<jndi-name>MySQLDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/db</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name></user-name>
<password></password>
</local-tx-datasource>


One DB is mysql .

I need to connect to another DB which might be any .Can any one give ideas how to add the configuration information for other db so that my other CMP looks out for that.

Put it another way how to tell to CMP to look to a different database.

regards
siva
 
VP Jain
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Did u try explicity mentioning your <resource-ref> in the ejb-jar.xml

for example

<enterprise-beans>
<session>
<description>ModuleA</description>
<ejb-name>ExampleBean</ejb-name>
<home> ...</home>
<remote>...</remote>
<ejb-class>....</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<resource-ref>
<res-ref-name>jdbc/XXX</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</session>
<session>
<description>ModuleB</description>
<ejb-name>ExampleBean</ejb-name>
<home> ...</home>
<remote>...</remote>
<ejb-class>....</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<resource-ref>
<res-ref-name>jdbc/YYY</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</session>

and i think u need to modify the <default> tag in JBOSS.

-regards
Parsuvanath.V
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic