• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

more than one data-source in Struts

 
Abebe Belew
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to have connection to two different databases in struts.
in my struts-config.xml file I set up two <data-sources> as

<data-sources>
<data-source>
<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" />
</data-source>

<data-source>
<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" />
</data-source>

</data-sources>

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
Marshal
Pie
Posts: 65125
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this would more approriate in the Struts forum, so moving it there.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic