Hi Phillipe,

you can do it like this:

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

and then

var db_conn = Database.getConnection("CordobaJDBC");

Unfortunately, the load will just work if you have the samples included (it's from the "petstore" block). In case you don't have that, I attach the source below.

Let me know if that still works, I didn't use it for a couple of years.

Cheers,
Johannes

Philippe Gauthier - INSERM SIRH wrote:
Hi everyone,

I would like to get a jdbc connection or its url/login/pass as defined in the cocoon.xconf and use it from the flowscript.
Example from cocoon.xconf
<jdbc name="CordobaJDBC">
       <pool-controller max="10" min="5" oradb="true"/>
       <dburl>jdbc:oracle:thin:@xx.xxxxx.xxxx:1564:XXXXX01</dburl>
       <user>XXXX</user>
       <password>XXXX</password>
</jdbc>

For now I use global variable defined in the sitemap and pass them to the flowscript, but that's not clean.
Thx for your help.

defineClass("org.apache.cocoon.components.flow.javascript.ScriptableConnection");
defineClass("org.apache.cocoon.components.flow.javascript.ScriptableResult");

Database.getConnection = function(selectorValue) {
var selector = cocoon.getComponent(Packages.org.apache.avalon.excalibur.datasource.DataSourceComponent.ROLE + "Selector");
   try {
       var ds = selector.select(selectorValue);
       return new Database(ds.getConnection());
   } finally {
       cocoon.releaseComponent(selector);
   }
}





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to