You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jimmy Emmanual <ji...@imsi.com> on 2003/03/20 01:18:11 UTC
Connection Pool
How do you access a DataSource from an action class via its "key"? I have
multiple DataSources defined in the struts-config.xml file each have the
"key" property set. I need to access these based on this "key".
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Connection Pool
Posted by Stephen Smithstone <sk...@lchost.co.uk>.
Heres how i do it and it works with struts 1.1rc1
in the struts-config i have
<data-sources>
<data-source key="SystemsLog">
<set-property value="jdbc:mysql://localhost/SystemsLog" property="url"
/>
<set-property value="org.gjt.mm.mysql.Driver" property="driverClass" />
<set-property value="user" property="user" />
<set-property value="password" property="password" />
</data-source>
</data-sources>
then to get the datasource in a struts action i do
javax.sql.Datasource ds = this.getDatasource( httpServletRequest ,
"SystemsLog" );
java.sql.Connection conn = ds.getConnection( );
as the Action has a method to retreive a datasource for it
On Thursday 20 March 2003 12:18 am, Jimmy Emmanual wrote:
> How do you access a DataSource from an action class via its "key"? I have
> multiple DataSources defined in the struts-config.xml file each have the
> "key" property set. I need to access these based on this "key".
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org