Connection to Oracle

This document explains the specific aspect of connecting Cocoon to an Oracle Database.

For a general explanation on database connection please refer to the official documentation . It may also be worth your while to search the Oracle FAQ site.

Downloading the jdbc drivers

The jdbc drivers can be downloaded here .

Drop the classes12.zip file either in $COCOON_HOME/web-inf/lib or $TOMCAT_HOME/common/lib/.

Setting Web.xml

In the $Cocoon_Home/WEB-INF/ directory you will find the web.xml file. Open it and look for this rows

<init-param>
  <param-name>load-class</param-name> 
    <param-value>
<!-- 
 For IBM WebSphere:
        com.ibm.servlet.classloader.Handler ..-->

here you have to add the following line:

<!--  For Oracle:   --> 
  	  oracle.jdbc.driver.OracleDriver 

Setting cocoon.xconf

search for:
<datasources>
add into this element these lines:

  <jdbc name="YourPoolName">
    <pool-controller min="5" max="10" oradb="true"/>
    <dburl>jdbc:oracle:thin:@YourServerName:1521:SID</dburl>
    <user>YourUsername</user>
    <password>YourPassword</password>
  </jdbc>

Setting sitemap.xmap

When you want to use the connection you just call the jdbc name inside the pipeline in this way:

<map:match pattern="sqlquery">
  <map:generate src="sql/sqlquery.xml"/>
  <map:transform type="sql">
    <map:parameter name="use-connection" value="YourPoolName"/>
  </map:transform>
  <map:transform type="xslt" src="../stylesheets/transformation.xslt"/>
  <map:serialize type="svg2jpeg"/>
</map:match>

Obviously you have to adapt this sample to fill your need.

SpecificDatabaseConnection

Comments from the readers

The Oracle 8.1.7 jdbc driver apparently has to be provided as a jar file instead of the standard classes12.zip, or the class loader won't find the driver class.

  • No labels