File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes more than one data-source in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "more than one data-source in Struts" Watch "more than one data-source in Struts" New topic

more than one data-source in Struts

Abebe Belew

Joined: Jul 21, 2004
Posts: 19
I want to have connection to two different databases in struts.
in my struts-config.xml file I set up two <data-sources> as

<set-property property="key" value="mysql"/>
<set-property property="autoCommit" value="true" />
<set-property property="description" value="MySql Datasource" />
<set-property property="driverClass" value="com.mysql.jdbc.Driver" />
<set-property property="maxCount" value="5" />
<set-property property="minCount" value="2" />
<set-property property="user" value="user" />
<set-property property="password" value="pass" />
<set-property property="url" value="jdbc:mysql://url ort/db_name" />

<set-property property="key" value="tiger"/>
<set-property property="autoCommit" value="true" />
<set-property property="description" value="java Datasource" />
<set-property property="driverClass" value="oracle.jdbc.driver.OracleDriver" />
<set-property property="maxCount" value="5" />
<set-property property="minCount" value="2" />
<set-property property="user" value="usr" />
<set-property property="password" value="pass" />
<set-property property="url" value=
jdbc racle:thin:@url ort b_name" />


I tried to access both connections in my Action as

javax.sql.DataSource dataSource_udb;
java.sql.Connection conn_tiger;
javax.sql.DataSource dataSource_mysql;
java.sql.Connection conn_mysql;

dataSource_udb = getDataSource(request, "tiger");
conn_tiger = dataSource_udb.getConnection();

dataSource_mysql = getDataSource(request);
conn_mysql = dataSource_mysql.getConnection();

but then i get an error message "Servlet action is currently unavailable" and in the log file
javax.servlet.UnavailableException: Initializing application data source org.apache.struts.action.DATA_SOURCE
I have been stuck with this for more than a week now. can anybody help me with this.
thanks so much.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63838

I think this would more approriate in the Struts forum, so moving it there.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: more than one data-source in Struts
jQuery in Action, 3rd edition