cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aurélien DEHAY ...@zorel.org>
Subject Re: Using database pool from java object for flow
Date Tue, 29 Mar 2005 15:37:04 GMT
Hello.

Le mardi 29 mars 2005 à 10:00 -0500, André Thénot a écrit :
> Hi,
> 
> I'm using flow to talk to my java model classes. So far so good.
>    But I'd like my model classes to talk to the database and use 
> cocoon's connection pool. Do I have to write an Avalon component for 
> this? If so, how does one go about to do this (I don't know anything 
> about writing those)?

The petstore block have this functionnality (the cocoon-petstore.jar
contains only the .js which do this), build the petstore without the
samples and:

cocoon.load("resource://org/apache/cocoon/components/flow/javascript/Database.js");

And, in your function:
try {
        var conn = Database.getConnection("connectionName");

        // On balance une serie de requete et on stocke les resultats
        var content = conn.query("request, use ? as parameter",
[parameter ]).rows[0];
} finally {
	conn.close();
}

look at the
cocoon-2.1.7/src/blocks/petstore/samples/flow/PetStoreImpl.js it has a
lot of database use in flows.

Rgds.

> 
> Any pointers would be greatly appreciated.
> Thanks,
> 
> Andre.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message