Declaring the datasource as a JNDI resource

You will first of all need to create a DAR file using the deployment descriptor editor:

NB: basically, you need a ConnectionPoolDataSource, whatever the database driver you are using (I'm using inet.jar for SQLServer)

Alternatively, you can simply deploy a jndi-definitions.xml file (rather than a DAR file):
{{{<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jndi-definitions PUBLIC "-//Borland Corporation//DTD JndiDefinitions//EN" "">\\ <jndi-definitions>


Declaring the JNDI resource within the web application

Now for your web application, you need to specify how to map the JNDI datasource in your web app:
in web.xml, you will need to define the resource reference for your datasource (at the end of the provided sample)
{{{<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" ""> <web-app>


In addition, you also need to include a web-borland.xml file which effectively provides the mapping between
the resource reference and the JNDI datasource:
{{{<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Borland Software Corporation//DTD Web Application 2.3//EN"


And in cocoon.xconf, you simply declare your J2EE datasource:
{{{ ...

All you need to do is to deploy your DAR file (or jndi-definitions.xml) and web application and you should be
able to use the datasource from you cocoon servlet.

JNDIDatasourceWithBorlandEnterpriseServer5.1 (last edited 2009-09-20 23:39:59 by localhost)