Connecting with the com.ibm.as400.access.AS400JDBCDriver in the plain standard way described As400 unfortunately seems to only work with JDK 1.4.0 or later.
If you need all Cocoon SQL functionality
If you need all Cocoon SQL functionality (XSP and SQLTransformer) you probably need to switch to JDK 1.4, which means:
downloading and installing a JDK 1.4.0 or later from Sun (current successful configurations use version 1.4.1);
have Tomcat use the upgraded JDK (by changing its $JAVA_HOME);
have all applications hosted in your Tomcat instance use a 1.4-targeted version of Cocoon.
Currently, version 2.0.3 has a ready-made, 1.4-targeted binary distribution in the download directory.
If your applications are Cocoon 2.0.3-based, the following should be enough: 1.# Locate cocoon-2.0.3-vm14-bin.tar.gz or cocoon-2.0.3-vm14-bin.zip in Cocoon's distribution directory and download the one which suits yout platform. 1.# unpack the file in a directory of your choice; 1.# unpack the cocoon.war which has been extracted: it expands to a full webapp directory structure; 1.# locate the WEB-INF/lib directory: it contains the same JARs as your 2.0.3 application's WEB-INF/lib directory, but retargeted at the JDK 1.4; 1.# after making a backup copy :), overwrite your application's Cocoon JARs with these new 1.4 ones; 1.# Restart Tomcat or simply reload your application(s) via the Tomcat Manager.- If your applications are based on another Cocoon version, you need to manually rebuild Cocoon from the source, targetting at the JDK 1.4, and then start from previous point 4.
If you don't need/use SQLTransformer and are happy with ESQL
Then maybe you could stick with JDK 1.3 without changing other applications, and retain your current Tomcat setup except for minor changes.
The trick is to not use Cocoon's built-in connection pooling facility (provided by Avalon), but rather use your servlet container's one. Currently, this has been tested on Tomcat, which uses connection pooling services provided by Apache Commons DBCP.
You need to:
Let the com.ibm.as400.access.AS400JDBCDriver be accessible by Tomcat at its startup by copying jt400.jar to $TOMCAT_HOME/common/lib;
Add to Tomcat's server.xml configuration file (located in $TOMCAT_HOME/conf) the desired JDBC connection as a JNDI resource:
<Resource name="jdbc/as400" auth="Container" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/as400"> <parameter> <name>username</name> <value><$YOUR_USERNAME></value> </parameter> <parameter> <name>password</name> <value><$YOUR_PASSWORD></value> </parameter> <parameter> <name>driverClassName</name> <value>com.ibm.as400.access.AS400JDBCDriver</value> </parameter> <parameter> <name>url</name> <value>jdbc:as400://<$YOUR_HOST>/<$YOUR_COLLECTION></value> </parameter> </ResourceParams>1.#Please note that you can append a ;trace=true option to the JDBC URL, as well as any other options documented in JTOpen documentation. The trace option obviously kills performance, but allows you to debug connection problems by writing a quite detailed log to System.out, which in Tomcat default configuration gets logged to $TOMCAT_HOME/logs/catalina.out. 1.#Please also note that the snippet above must be inserted inside the relevant <Context/> element for your application. If you didn't define one (just dropped something into the webapps directory), putting it in the <GlobalNamingResources> could work (?).
Add to your application's cocoon.xconf file a reference to the J2EE connection you have just defined:{{{<datasources>
- ..
<j2ee name="$CONNECTION_NAME">
<dbname>as400</dbname>
</j2ee>
- ..
- ..
</datasources>}}} Please note that $CONNECTION_NAME is the name you want to use in your Cocoon application.
The <dbname/> string is, instead, the name you chose in server.xml's resource definition.
Note that server.xml's resource name is jdbc/as400, where <dbname/> only contains as400. This is because database connections are usually looked up inside the jdbc/ hierarchy.
This latter JNDI configuration is obviously only a "desperation-workaround", since it has shown problems with SQLTransformer.
Switching to JDK 1.4 should be seen as the best option, since it seems to allow all Cocoon SQL functionality to be used on databases stored on our AS/400 boxes.
A final note
Please note that all the above has been tested on Tomcat 4.1.12.
(Lorenzo)