Finally I have went through the Struts source code and I've found that
datasource has property named key that you can use to distinguish between
multiple datasources. 

Here is example:


<data-sources>
    <data-source
      key="TBS"
      autoCommit="false"
      description="Example Data Source Configuration"
      driverClass="oracle.jdbc.driver.OracleDriver"
         maxCount="8"
         minCount="4"
         password="test"
             user="test"
              url="jdbc:oracle:thin:@10.1.0.1:1521:testdat"
    />


later in the action code you retrieve desired connection as follows:

java.sql.Connection connection =
servlet.findDataSource("TBS").getConnection();


                -----Original Message-----
                From:   Zeltser, Mark [mailto:[EMAIL PROTECTED]]
                Sent:   Monday, April 09, 2001 10:52 AM
                To:     '[EMAIL PROTECTED]'
                Subject:        RE: How to use multiple datasources ?

                I am interested in this one too...

                Mark.

                > -----Original Message-----
                > From: Szlapa, Michael [SMTP:[EMAIL PROTECTED]]
                > Sent: Friday, April 06, 2001 2:05 PM
                > To:   '[EMAIL PROTECTED]'
                > Subject:      How to use multiple datasources ?
                > 
                > Does anyone know how to configure and use multiple
datasources ?
                > 
                > Thanks in advance
                > Michael
                > 
                > 
                > 
                >               -----Original Message-----
                >               From:   Szlapa, Michael
                > [mailto:[EMAIL PROTECTED]]
                >               Sent:   Wednesday, April 04, 2001 11:11 AM
                >               To:     '[EMAIL PROTECTED]'
                >               Subject:        How to use multiple
datasources ?
                > 
                >               Hi
                > 
                >               I have problems understanding how I should
configure
                > multiple datasources to
                >               be used in single application, possibly even
in single
                > Action or JSP page.
                > 
                >               I've read in API description of
ActionServlet.dataSources
                >                       The JDBC data sources that has been
configured for
                > this application,
                >               if any, keyed by the servlet context
attribute under which
                > they are stored.
                > 
                >               I guess I don't understand what "servlet
context attribute"
                > means here,  I
                >               have only one application with one servlet
(ActionServlet),
                > how I should
                >               configure name of the context attribute ? 
                > 
                >               I think it would be nice if I could specify
datasource name
                > in the
                >               struts-config like:
                > 
                >               <data-sources> 
                >                 <data-source autoCommit="false" 
                >                       name="My name"
                >                       description="Trial access to
database" 
                >
driverClass="oracle.jdbc.driver.OracleDriver" 
                >               maxCount="4"     minCount="2" 
                >               password="123" 
                >               url="jdbc:oracle:thin:@ado:1521:123" > >
user="123" /> 
                >               </data-sources> 
                > 
                >               and then do  findDataSource("My name");
                > 
                >               I have looked also at the Struts guide to
find more about
                > <data-source>
                >               section, but it only talks about default
connection. 
                > 
                >               TIA
                >               Michael 
                >               


        
----------------------------------------------------------------------------
--
                This message is intended only for the personal and
confidential use of the designated recipient(s) named above.  If you are not
the intended recipient of this message you are hereby notified that any
review, dissemination, distribution or copying of this message is strictly
prohibited.  This communication is for information purposes only and should
not be regarded as an offer to sell or as a solicitation of an offer to buy
any financial product, an official confirmation of any transaction, or as an
official statement of Lehman Brothers Inc.  Email transmission cannot be
guaranteed to be secure or error-free.  Therefore, we do not represent that
this information is complete or accurate and it should not be relied upon as
such.  All information is subject to change without notice.
                

Reply via email to