You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by virupaksha <vi...@hotmail.com> on 2003/09/19 05:26:51 UTC
Data Source in struts-config.xml
Dear All,
I need to connect to two different databases,MS Access & MYSQL.
I am connecting databases using JNDI lookup,so to connect using JNDI lookup i need to give database name in my code.
Can any one help me how i can configure two datasource name in struts-config.xml.
Waiting for ur help...
Regards,
viru
Re: Data Source in struts-config.xml
Posted by Andrew Kuzmin <ku...@soft-ukraine.com>.
<snip from="http://jakarta.apache.org/struts/faqs/database.html">
If you need more than one data source in a module, you can include a key
attribute in the data-source element:
<data-sources>
<data-source key="A" type="org.apache.commons.dbcp.BasicDataSource">
... properties as before ...
</data-source>
<data-source key="B" type="org.apache.commons.dbcp.BasicDataSource">
... properties as before ...
</data-source>
...
</data-sources>
Which can then be accessed by including the key ("A" in this case) as an
additional parameter to the Action.getDataSource() method.
...
try {
dataSourceA = getDataSource(request, "A");
dataSourceB = getDataSource(request, "B");
...
Each module can have as many data sources as it needs. The keys only need to
be unique within a module since the struts module system maintains a name
space for the items in each module to protect you from name clashes.
</snip>
--
Andrew Kuzmin
http://www.java201.com
>----- Original Message -----
>From: "virupaksha" <vi...@hotmail.com>
>To: "Struts Users Mailing List" <st...@jakarta.apache.org>
>Sent: Friday, September 19, 2003 6:26 AM
>Subject: Data Source in struts-config.xml
>Dear All,
>I need to connect to two different databases,MS Access & MYSQL.
>I am connecting databases using JNDI lookup,so to connect using JNDI lookup
i need to give database name in my code.
>Can any one help me how i can configure two datasource name in
struts-config.xml.
>Waiting for ur help...
>Regards,
>viru
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org