Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Struts - A MVC web framework
Tomcat - JSP/Servlet container
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
JSP - A mailing list about Java Server Pages specification and reference
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Accessing Different DBs from State less EJB

Accessing Different DBs from State less EJB

2003-11-02       - By Christophe Th�paut

 Back
Reply:     1     2     3     4     5     6  

Hi



Using the abstract factory with a DAO will not help. These patterns only
allow you to choose different databases with no or little changes on the
client side (SQL statements). Here your databases are DB2. You're fine about
it.



What you need here is to manage transactional behaviours. The exception is
pretty clear about it: An illegal attempt to use multiple resources that
have only one-phase capability has occurred within a global transaction.



Either you manage your transactions using EJBs (session beans in your case)
or a transactional middleware.



If you go with EJBs then you need to choose between Container Managed
Transaction and define transactional demarcation in the ejb-jar.xml
descriptor or Bean Managed Transaction and define transaction
programmatically using JTA. Beware that you can not use both. You need to
choose one or another and stick with it.



If you go with a transactional middleware such as BEA Tuxedo for instance
(IBM must have one but I can't recall) then you can not manage transactions
using EJBs.



What is a little scary about your issue here is that transactional
management should have been defined by your Architect in a Software
architecture document or/and in a Design Model.



Good luck.



Christophe

SCEA for J2EE



 __ __

From: An interest list for Sun Java Center J2EE Pattern Catalog
[mailto:J2EEPATTERNS-INTEREST@(protected)] On Behalf Of Anil Kumar
Sent: Sunday, November 02, 2003 7:22 AM
To: J2EEPATTERNS-INTEREST@(protected)
Subject: Re: Accessing Different DBs from State less EJB



Ashraf,



Iam  implementing DAO the same way as you told. I am following the core J2EE
design
patterns.



Thanks

Anil


ashraf galal <ashrafwg@(protected)> wrote:

Anil;

you must implement it usaing the abstract factory pattern.

the pattern looks like the following class diagram:

Figure 9.8
<http://java.sun.com/blueprints/corej2eepatterns/Patterns/images09/figure09_
08.gif>

I hope this might help you.

Best wishes

Ashraf Galal

EAI Senior Architect
(416)804-8359

>From: Anil Kumar

>Reply-To: An interest list for Sun Java Center J2EE Pattern Catalog

>To: J2EEPATTERNS-INTEREST@(protected)

>Subject: Accessing Different DBs from State less EJB

>Date: Sat, 1 Nov 2003 21:45:41 -0800

>

>Hi,

>

>I had a Stateless session Bean and DAO to access 4 databases. But as per my
requirement I have to get data from different databases one after other in
EJB.

>I am getting data from First DB then when it is trying to create the
statement for second DB its throwing the error.

>

>WTRN0062E: An illegal attempt to use multiple resources that have only
one-phase capability has occurred within a global transaction.

>

>I am using Websphere application server (WSAD) with
COM.ibm.db2.jdbc.app.DB2Driver

>(JDBC 2.0) Database is DB2.

>

>

>Please help me out

>

>Thanks a lot

>Anil

>

>

>

>

>-- ---- ---- ---- ---- ---- -----

>Do you Yahoo!?

>Exclusive Video Premiere - Britney Spears

>

>====================================================================

>Companion Site: http://www.corej2eepatterns.com

>J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns

>List Archive:
http://archives.java.sun.com/archives/j2eepatterns-interest.html

>Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to
listserv@(protected)





 __ __


Tired of spam? Get advanced <http://g.msn.com/8HMAENCA/2734??PS=>  junk mail
protection with MSN 8.
====================================================================
Companion Site: http://www.corej2eepatterns.com J2EE BluePrints:
http://java.sun.com/blueprints/corej2eepatterns List Archive:
http://archives.java.sun.com/archives/j2eepatterns-interest.html
Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to
listserv@(protected)

 __ __

Do you Yahoo!?
Exclusive Video Premiere - Britney
<http://launch.yahoo.com/video/?1093432&fs=1&redirectURL=http://launch.yahoo
.com/promos/britneyspears/>  Spears
====================================================================
Companion Site: http://www.corej2eepatterns.com J2EE BluePrints:
http://java.sun.com/blueprints/corej2eepatterns List Archive:
http://archives.java.sun.com/archives/j2eepatterns-interest.html
Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to
listserv@(protected)


====================================================================
Companion Site: http://www.corej2eepatterns.com
J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns
List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html
Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)

<html>

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered)">
<style>
<!--
/* Font Definitions */
@(protected)
       {font-family:Tahoma;
       panose-1 (See http://ose-1.ora-code.com):2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
       {margin:0cm;
       margin-bottom:.0001pt;
       font-size:12.0pt;
       font-family:"Times New Roman";}
a:link, span.MsoHyperlink
       {color:blue;
       text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
       {color:blue;
       text-decoration:underline;}
p
       {margin-right:0cm;
       margin-left:0cm;
       font-size:12.0pt;
       font-family:"Times New Roman";}
span.EmailStyle18
       {color:black;}
@(protected) Section1
       {size:595.3pt 841.9pt;
       margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.Section1
       {page:Section1;}
-->
</style>

</head>

<body lang=FR link=blue vlink=blue>

<div class=Section1>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
lang=EN-GB style='font-size:12.0pt;color:black'>Hi</span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
lang=EN-GB style='font-size:12.0pt;color:black'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
lang=EN-GB style='font-size:12.0pt;color:black'>Using the abstract factory with
a DAO will not help. These patterns only allow you to choose different databases
with no or little changes on the client side (SQL statements). Here your
databases are DB2. You&#8217;re fine about it.</span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
lang=EN-GB style='font-size:12.0pt;color:black'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
lang=EN-GB style='font-size:12.0pt;color:black'>What you need here is to manage
transactional behaviours. The exception is pretty clear about it: </span></font
><span
lang=EN-GB>An illegal attempt to use multiple resources that have only
one-phase capability has occurred within a global <b><u><span style='font
-weight:
bold'>transaction</span></u></b>. </span></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt'>Either you manage your transactions using EJBs (session
beans in your case) or a transactional middleware.</span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt'>If you go with EJBs then you need to choose between
Container Managed Transaction and define transactional demarcation in the ejb
-jar.xml
descriptor or Bean Managed Transaction and define transaction programmatically
using JTA. Beware that you can not use both. You need to choose one or another
and stick with it.</span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt'>If you go with a transactional middleware such as BEA
Tuxedo
for instance (IBM must have one but I can&#8217;t recall) then you can not
manage transactions using EJBs.</span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-GB
style='font-size:12.0pt'>What is a little scary about your issue here is that
transactional management should have been defined by your Architect in a
Software architecture document or/and in a Design Model. </span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
lang=EN-GB style='font-size:12.0pt;color:black'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
lang=EN-GB style='font-size:12.0pt;color:black'>Good luck.</span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
lang=EN-GB style='font-size:12.0pt;color:black'>&nbsp;</span></font></p>

<div>

<p class=MsoNormal><b><font size=2 color=black face=Tahoma><span lang=EN-GB
style='font-size:10.0pt;font-family:Tahoma;color:black;font-weight:bold'
>Christophe</span></font></b></p>

<p class=MsoNormal><i><font size=2 color=black face=Tahoma><span lang=EN-US
style='font-size:10.0pt;font-family:Tahoma;color:black;font-style:italic'>SCEA
for
J2EE</span></font></i></p>

</div>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt;color:black'>&nbsp;</span></font></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> An interest list
for Sun Java Center J2EE Pattern Catalog
[mailto:J2EEPATTERNS-INTEREST@(protected)] <b><span style='font-weight:bold'>On
Behalf Of </span></b>Anil Kumar<br>
<b><span style='font-weight:bold'>Sent:</span></b> Sunday, November 02, 2003
7:22 AM<br>
<b><span style='font-weight:bold'>To:</span></b>
J2EEPATTERNS-INTEREST@(protected)<br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: Accessing Different
DBs from State less EJB</span></font></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;</span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Ashraf,</span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;</span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Iam &nbsp;implementing DAO the same way as you told. I am following the
core J2EE design <br>
patterns.</span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;</span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Thanks</span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Anil</span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><br>
<b><i><span style='font-weight:bold;font-style:italic'>ashraf galal
&lt;ashrafwg@(protected)&gt;</span></i></b> wrote:</span></font></p>

</div>

<blockquote style='border:none;border-left:solid #1010FF 1.0pt;padding:0cm 0cm
0cm 3.0pt;
margin-left:2.5pt;margin-top:5.0pt;margin-bottom:5.0pt'>

<div>

<div>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>Anil;<
/span></font></p>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>you must
implement it usaing the abstract&nbsp;factory pattern.</span></font></p>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>the&nbsp
;pattern
looks like the following class diagram:</span></font></p>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'><img
width=459 height=469
src="http://java.sun.com/blueprints/corej2eepatterns/Patterns/images09/figure09
_08.gif"
alt="Figure 9.8" align=bottom border=0 name=Graphic8></span></font></p>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>I hope
this might help you.</span></font></p>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>Best
wishes</span></font></p>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>Ashraf
&nbsp;Galal</span></font></p>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>EAI
Senior Architect&nbsp;<br>
(416)804-8359</span></font></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;From: Anil Kumar </span></font></p>

<ANIL007DC@(protected)>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;Reply-To: An interest list for Sun Java Center J2EE Pattern Catalog
</span></font></p>

<J2EEPATTERNS-INTEREST@(protected)>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;To: J2EEPATTERNS-INTEREST@(protected) </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;Subject: Accessing Different DBs from State less EJB </span></font>
</p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;Date: Sat, 1 Nov 2003 21:45:41 -0800 </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt; </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;Hi, </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt; </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;I had a Stateless session Bean and DAO to access 4 databases. But
as per my requirement I have to get data from different databases one after
other in EJB. </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;I am getting data from First DB then when it is trying to create
the statement for second DB its throwing the error. </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt; </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;WTRN0062E: An illegal attempt to use multiple resources that have
only one-phase capability has occurred within a global transaction. </span><
/font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt; </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;I am using Websphere application server (WSAD) with
COM.ibm.db2.jdbc.app.DB2Driver </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;(JDBC 2.0) Database is DB2. </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt; </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt; </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;Please help me out </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt; </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;Thanks a lot </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;Anil </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt; </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt; </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt; </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt; </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;-- ---- ---- ---- ---- ---- ----- </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;Do you Yahoo!? </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;Exclusive Video Premiere - Britney Spears </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt; </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;====================================================================
</span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;Companion Site: http://www.corej2eepatterns.com </span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns <
/span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;List Archive:
http://archives.java.sun.com/archives/j2eepatterns-interest.html </span></font>
</p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&gt;Unsubscribing: email &quot;signoff J2EEPATTERNS-INTEREST&quot; to
listserv@(protected)
</span></font></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><br clear=all>
</span></font></p>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center>

</span></font></div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Tired of spam? Get <a href="http://g.msn.com/8HMAENCA/2734??PS="
>advanced
junk mail protection</a> with MSN 8.
==================================================================== Companion
Site: http://www.corej2eepatterns.com J2EE BluePrints:
http://java.sun.com/blueprints/corej2eepatterns List Archive:
http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing:
email &quot;signoff J2EEPATTERNS-INTEREST&quot; to listserv@(protected)</span>
</font></p>

</blockquote>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=1 width="100%" align=center>

</span></font></div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Do you Yahoo!?<br>
Exclusive Video Premiere - <a
href="http://launch.yahoo.com/video/?1093432&amp;fs=1&amp;redirectURL=http:/
/launch.yahoo.com/promos/britneyspears/">Britney
Spears</a> ====================================================================
Companion Site: http://www.corej2eepatterns.com J2EE BluePrints:
http://java.sun.com/blueprints/corej2eepatterns List Archive:
http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing:
email &quot;signoff J2EEPATTERNS-INTEREST&quot; to listserv@(protected)</span>
</font></p>

</div>

</body>

</html>
====================================================================
Companion Site: http://www.corej2eepatterns.com
J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns
List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html
Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.