apache > cocoon

Database FAQs

When I try to use the Connection pooling code, I get the following exception: "Could not get the datasource java.sql.SQLException: You cannot get a Poolable before the pool is initialized". What's going on?

The most common reason for this exception is that the driver was not loaded. Cocoon uses an initial parameter in the "web.xml" file to automatically load classes on startup. This way, the class is loaded only once and the server's time is spent doing more productive things. Make sure the following entry is in your "web.xml" file.

   <!-- comma or whitespace separated list of fully
     qualified class names to load on startup.

If the class is loaded correctly, and you are still getting this error, then there is probably an error in your connection information. The SQLException above is thrown when there are no open connections to the database.

The sql samples don't run.

The sql samples are working when deploying the war file using the build system:

./build.sh \
   -Dinstall.war=path/to/tomcat/webapps install

This command will take care of the path inside the configuration file to the database resources.

I've been able to run the database samples, but they don't run anymore.

This happens when the servlet engine has been stopped abruptly (e.g. with ctrl-C).

Hsqldb - the database used by C2 samples - is a single-process engine that locks the database by setting the "modified" entry in "WEB-INF/db/cocoondb.properties" to the value "yes" while some JDBC connections exist.

With connection pooling, there's always some connections opened, and they're not closed properly when you stop abruptly the servlet engine, so the database stays in locked state and connections are refused at the next server startup.

To unlock the database, change manually "modified" to "no" in the "cocoondb.properties" before restarting the server.

I get an AbstractMethodError when Cocoon tries to query my database.

In this case Cocoon returns a "500 internal error" result, and the AbstractMethodError is visible in the tomcat logs after a call to Connection.prepareStatement(...).

This happens when the JDBC driver being used does not implement the JDBC 1.2 interfaces: using its default configuration, the SQLTransformer calls a version of the JDBC Connection.prepareStatement(...) method that is not available in pre-1.2 drivers.

To avoid this problem, configure the SQLTransformer with "old-driver=true" in the sitemap, as shown in this example:


Where can I find more information about connecting to databases using Cocoon?

Learn more about connecting to databases by downloading the free chapter, A User's Look at the Cocoon architecture, from Langham and Ziegeler's Cocoon: Building XML Applications available at the New Riders web site.