wood burning stoves 2.0*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Regarding two database access. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Regarding two database access." Watch "Regarding two database access." New topic
Author

Regarding two database access.

sivakumar ganti
Greenhorn

Joined: Jan 19, 2004
Posts: 22
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

Joined: Feb 11, 2004
Posts: 81
Hi,

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

Coz....it depends on the container.

-Regards
Parsuvanath.


SCJP SCWCD SCBCD <br /> <br />what u do in life echos in eternity!
sivakumar ganti
Greenhorn

Joined: Jan 19, 2004
Posts: 22
I am using JBOSS 3.2.3 .

thankx
siva
Nitin Singh
Greenhorn

Joined: Oct 14, 2004
Posts: 24
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

Joined: Jan 19, 2004
Posts: 22
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

Joined: Feb 11, 2004
Posts: 81
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding two database access.
 
Similar Threads
Transaction Rollback Fails
Transaction Timeout Exception in cmp
strange error causing JVM to hang..???
Regarding two database access.
EJB CMP Vs. BMP performance