cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Haul <h...@dvs1.informatik.tu-darmstadt.de>
Subject Re: Databases & Action
Date Mon, 13 May 2002 16:19:59 GMT
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: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message