cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conrad F. D'Cruz" <conrad.dc...@netswirl.com>
Subject Try this Re: Can't connect to MySQL with Cocoon 2
Date Sun, 05 May 2002 13:35:41 GMT
Daniel,

Maybe I don't understand using databases with Cocoon after all.  Are you
using
the database for logging?  If not why did you define it in the <jdbc>
block in the xconf
file that way (as a logger)?

Here is what I did to get it working (and I got these steps from the
userdocs)

1) I put the mysql.jar file (which contains the mysql jdbc driver) in the
tomcat4.01/lib directory.
    I vaguely remember having trouble when it was in the
cocoon/WEB-INF/lib ... and once
    it started working I did not complain or spend additional time
researching why it failed
    down in the lower directory.

2) I created a jdbc block in the cocoon.xconf file as follows ...

       <jdbc name="mysql_pool">
         <pool-controller min="5" max="10"/>
         <dburl>jdbc:mysql://localhost/mydb</dburl>
         <user>root</user>
         <password></password>
       </jdbc>

where ... mydb is the (very creative) name I chose for the database.

3) In the webapps/cocoon/WEB-INF directory ... I put the following in
the web.xml file ...

    <init-param>
      <param-name>load-class</param-name>
      <param-value>

        <!-- For MySQL on localhost-->
        org.gjt.mm.mysql.Driver

     <!-- For JDBC-ODBC Bridge: -->
        sun.jdbc.odbc.JdbcOdbcDriver

        <!-- For parent ComponentManager sample:
        org.apache.cocoon.samples.parentcm.Configurator  -->
      </param-value>
    </init-param>

4) Finally I use the mysql_pool, as follows

In  the sitemap ... within the <map:pipeline>the transformer looks like
this

      <map:transform type="sql">
        <map:parameter name="use-connection" value="mysql_pool"/>

5) In the content source file for the <map:generator> component I have
this code ...
(note there is more than just this code in the file.  In the interest of
space I am just
showing the sql stuff)

  <execute-query xmlns="http://apache.org/cocoon/SQL/2.0">
   <query>
        select * from emp where name='Conrad'
   </query>
  </execute-query>

(of course there was a table named emp in mydb ... and it was set up
correctly and
I made sure there was data in that table -- I verified everything from the
"mysql" console)

... then I fired up Cocoon (and prayed for a miracle!!).  The C2 gods must
have
been pleased with me that day ... because ... it worked!!!

I, however, did not have a bottle of champagne when I saw the data in my
browser ...
but it worked!! and I was not going to complain about format etc etc.
That is the
topic for another bottle of champagne :)

Hope that helps
Conrad

bulk@daniel-vogelheim.de wrote:

> Hello all,
>
> I have a problem connecting to a MySQL database with Cocoon. When I
> try to access a page that goes through the SQLTransformer, the browser
> doesn't deliver any result. There's no error message, the browser just
> sits there and waits for data. The Coccon core.log file contains an
> error message "No valid Jdbc Connection class available". (More
> details follow below.)
>
> I've checked Google, the mailing list archive, and the FAQs, but
> didn't find anything that seemed to help. I'm surely missing
> something; aynone out there can help me?
>
> Thanks,
> Daniel
>


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message