You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Michael Mangeng <m1...@vis.at> on 2002/05/13 17:48:01 UTC
Databases & Action
Hi
I was wondering how i can access a pooled db connection within a action...
in the turorial at http://xml.apache.org/cocoon/developing/datasources.html is mentioned in the action example:
----
import org.apache.cocoon.Roles;
-----
the problem is that this class doesn´t exist in cocoon-2.0.2.jar....
is there another way to access the db or from where can i get this org.apache.cocoon.Roles class ?
greetings
mike
Re: Databases & Action
Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 13.May.2002 -- 05:48 PM, Michael Mangeng wrote:
> Hi
>
> I was wondering how i can access a pooled db connection within a action...
> in the turorial at http://xml.apache.org/cocoon/developing/datasources.html is mentioned in the action example:
> import org.apache.cocoon.Roles;
>
> the problem is that this class doesn´t exist in cocoon-2.0.2.jar....
>
> is there another way to access the db or from where can i get this org.apache.cocoon.Roles class ?
Please look at how it is done e.g. in AbstractDatabaseAction /
DatabaseAddAction and correct the docs :-)
Your action needs to implement the Composable interface:
/**
* Compose the Actions so that we can select our databases.
*/
public void compose(ComponentManager manager) throws ComponentException {
this.dbselector = (ComponentSelector) manager.lookup(DataSourceComponent.ROLE + "Selector");
super.compose(manager);
}
and then
DataSourceComponent datasource = (DataSourceComponent) this.dbselector.select(dataSourceName);
Connection conn = datasource.getConnection();
HTH
Chris.
--
C h r i s t i a n H a u l
haul@informatik.tu-darmstadt.de
fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>