Hi Phil,
On Sat, 5 Apr 2003, Phil Coultard wrote:
> Frustrated and feeling rather thick,
Don't worry, I've spent many hours on db connection problems, it's always
a sticking point and a nightmare to get sorted out.
Here's some step-by-step checks (worth repeating, as typos are often the
problem!):
1) Is the mysql server running and accepting connections?
- Test this using the mysql command-line client:
mysql -D your_db_name -h localhost -P 3306 -pyour_password -u your_user
Make sure you can select the information you want to use in the XSP (to
ensure the user you're connecting as has rights to the db and the
table):
SELECT foo FROM bar;
- Test connections with telnet:
telnet localhost 3306
(you should see something like "3.23.56-log$8,u+r}>" which shows you
can at least connect to localhost)
2) Is the (right) mysql jar available?
- Check that you downloaded the correct jar for your JDK, as jdbc
connectors are java version-specific.
- Check in $TOMCAT_HOME/webapps/cocoon/WEB-INF/lib/ for the presence of
mysql-connector-java-3.0.6-bin.jar or similar.
- Check that it is correctly referenced in WEB-INF/web.xml:
<init-param>
<param-name>load-class</param-name>
<param-value>
<!-- For Database Driver: -->
com.mysql.jdbc.Driver
</param-value>
</init-param>
3) Is the Cocoon database connection pool configured?
- Check that it's correctly configured in WEB-INF/cocoon.xconf:
<datasources>
<jdbc logger="core.datasources.your_db_name" name="your_db_name">
<pool-controller max="10" min="5"/>
<dburl>jdbc:mysql://localhost:3306/your_db_name</dburl>
<user>your_user</user>
<password>your_password</password>
</jdbc>
</datasources>
4) Is the XSP written correctly?
- Try the simplest possible XSP that could work, first:
<?xml version="1.0"?>
<xsp:page language="java" xmlns:xsp="http://apache.org/xsp"
xmlns:esql="http://apache.org/cocoon/SQL/v2">
<page>
<esql:connection>
<esql:pool>your_db_name</esql:pool>
<esql:execute-query>
<esql:query>SELECT foo FROM bar</esql:query>
<esql:results>
<esql:row-results>
<foo><esql:get-string column="foo"/></foo>
</esql:row-results>
</esql:results>
</esql:execute-query>
</esql:connection>
</page>
</xsp:page>
That said, from looking at what you've done so far, you've got everything
correct :-/
Andrew.
--
Andrew Savory Email: [EMAIL PROTECTED]
Managing Director Tel: +44 (0)870 741 6658
Luminas Internet Applications Fax: +44 (0)700 598 1135
This is not an official statement or order. Web: www.luminas.co.uk
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]