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 J�rn �lmheim

 Back
Reply:     1     2     3     4     5     6  

Hi.

You're on the right track here, Christophe, but not quite there.

The problem is as you correctly observe with transactions, but the problem
is with the database driver. This data base driver only one-phase commit,
and what you need when you use more than one resource in a transaction is
of course two-phase commit.

Anil: Switch to a database driver that supports XA connections (two-phase
commit), and that will solve your problem.

Best regards,
J�rn �lmheim
Senior Software Developer
Statoil ASA.



|-- -----+-- ---- ---- ---- ---- ---- ---- --->
|        |          Christophe Thepaut        |
|        |          <theo3285@(protected)>      |
|        |          Sent by: An interest list |
|        |          for Sun Java Center J2EE  |
|        |          Pattern Catalog           |
|        |          <J2EEPATTERNS-INTEREST@(protected)|
|        |          A.SUN.COM>                |
|        |                                    |
|        |                                    |
|        |          02.11.2003 09:55          |
|        |          Please respond to An      |
|        |          interest list for Sun Java|
|        |          Center J2EE Pattern       |
|        |          Catalog                   |
|        |                                    |
|-- -----+-- ---- ---- ---- ---- ---- ---- --->
 >-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---
-- ---- ---- ---- ---- ---- ---|
 |                                                                            
                              |
 |       To:     J2EEPATTERNS-INTEREST@(protected)                          
                              |
 |       cc:     (bcc: J�rn �lmheim)                                          
                              |
 |       Subject:     Re: Accessing Different DBs from State less EJB        
                              |
 >-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---
-- ---- ---- ---- ---- ---- ---|




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:





    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 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 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)







-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
The information contained in this message may be CONFIDENTIAL and is
intended for the addressee only. Any unauthorised use, dissemination of the
information or copying of this message is prohibited. If you are not the
addressee, please notify the sender immediately by return e-mail and delete
this message.
Thank you.
===================================================================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.