Connection to Microsoft Access (via odbc)

This document explains the specific aspects of connecting Cocoon to a Microsoft Access Database via odbc. This should work with any odbc compliant data source.

For a general explanation on database connections please refer to the official Cocoon documentation.

Installing the JDBC drivers

Setting the web.xml configuration

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


here you have to add the following line:

<!-- For ODBC: -->

Setting the cocoon.xconf configuration

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

  <jdbc name="YourPoolName">
    <pool-controller min="5" max="10"/>

Setting the sitemap.xmap configuration

When you want to use the connection with the SQLTransformer 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 type="xslt" src="../stylesheets/transformation.xslt"/>
  <map:serialize />

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

== Setting up ODBC Source
a. Start > Settings > Control Panel > Administrative Tools > Data sources (ODBC)
b. Select the tab labeled ‘System DSN’   (I tried User DSN, but it did not work!)
c. Click ‘Add’
d. Select the type of data source you want to create, e.g. Microsoft Access Driver
e. Supply a name for the data source (This needs to match the YourODBCSourceName cocoon.xconf!
f. The ‘description’ is optional
g. Click the ‘Select’ button under ‘Database’ to bring-up a file browse dialog
h. Use the dialog to select the database file 

Comments from the readers

Access (last edited 2009-09-20 23:42:59 by localhost)