Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

DataSources

Daniel Blumenthal

2007-03-14

Replies:

I'm looking into upgrading from 1.2.9 to 1.3.8, and I'm having a hard time
figuring out how to get DataSources for my application. In the old version,
I did the configuration in the struts-config.xml file, and could say the
following in the action:

DataSource ds = getDataSource(request,"datasourceID");

I understand that this was removed in 1.3, but it's unclear how to make the
switch. The documentation has a one-liner about using JNDI to get
DataSources, but I can't seem to find any examples. Here's the original
configuration:

<data-sources>
<data-source key="datasourceID"
type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="driverClassName" value="com.mysql.jdbc.Driver" />
<set-property property="url"
value="jdbc:mysql://localhost:3306/mydb?autoReconnect=true" />
<set-property property="maxActive" value="20" />
<set-property property="maxWait" value="5000" />
<set-property property="defaultAutoCommit" value="true" />
<set-property property="defaultReadOnly" value="false" />
<set-property property="username" value="strutsuser" />
<set-property property="password" value="foo" />
</data-source>
</data-sources>


Any help would be greatly appreciated!

Thanks!
Daniel



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.