cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ferran Urgell <urgsi...@yahoo.com>
Subject Re: Trying to connect mysql to cocoon2
Date Wed, 07 Nov 2001 07:38:21 GMT

 Thanks, for the answers,
I've another question: What I need to put in the sitemap, because this is not working.  I
think that I'm very near of the connexion...If you have more about this, or somtehing ....Thanks
Ferran
 
  Jeremy Aston <jeremyaston@yahoo.co.uk> wrote: 
 Hi Ferran, 
It's not too difficult to do.  I have done mine on an windows platform but the changes should
be the same for Linux. 
I'm using the mm jdbc driver - mm.mysql-2.0.4-bin.jar - which you can download from mysql.com.
 Put this jar into your $TOMCAT_HOME/webapps/cocoon/WEB-INF/lib folder.  There is another
mm jdbc driver but this looks to be older to me - I can't tell from a cursory look at the
docs which is the best one to use so if anyone can shed some light on this then please do.

In WEB.XML find the existing hsqldb entry or add a new init-param construct to do a load-class.
 The class you need to load is "org.gjt.mm.mysql.Driver".  It should look something like:

    <init-param>
      <param-name>load-class</param-name>
      <param-value> 
      <!-- For Database Driver: -->
      org.gjt.mm.mysql.Driver
        
      </param-value>
    </init-param>

In COCOON.XCONF comment out or remove the hsqlbb-server construct (assuming you are not using
it).

Find the datasources construct and put the JDBC url setting in there e.g.

  <datasources>
    <jdbc name="xcpt">
      <pool-controller min="5" max="10"/>
      <!--
          If you need to ensure an autocommit is set to true or
      false, then create the "auto-commit" element below.

      <auto-commit>false</auto-commit>

      The default is true.
      -->
      <dburl>jdbc:mysql://<IP ADDRESS>:3306/xcpt</dburl>
      <user>root</user>
      <password></password>

    </jdbc>
  </datasources>

This is assuming you are on port 3306.  note the JDBC datasource name "xcpt" and the reference
to the "xcpt" database in the JDBC url.  Obviously these will be different in your case, as
will the username/password.  The datasource name is what you need to use in your ESQL.  I
have also noticed that the you must put in a proper ip address.  I think I need to tweak my
server config as it does not recognise a host name, localhost or 127.0.0.1 in there.  I'm
new to mysql as well so I am sure it is a small config issue.

The following ESQL shows how you can call the above connection

<esql:connection>
  <esql:pool>xcpt</esql:pool>
  <esql:execute-query>
    <esql:query>SELECT title, description FROM page</esql:query>
    <esql:results>
      <table>
        <esql:row-results>
          <tr>
             <td><esql:get-string column="title"/></td>
             <td><esql:get-string column="description"/></td>
          </tr>
        </esql:row-results>
      </table>
    </esql:results>
    <esql:no-results>
       <p>Sorry, no results!</p>
    </esql:no-results>
  </esql:execute-query>
</esql:connection>

Note  the use of the same pool name as your JDBC datasource name.

That's it - should work!

Jez

 

 


  

 
Ferran Urgell <urgsimfe@yahoo.com> wrote: 
Hi, everybody! 

Well, I'm trying to connect in a database mysql (in linux) and I would to know, more about
this.

What can I do for to do this ? 

If there are somebody, that are made this before, please send me an email

Thanks

Ferran



---------------------------------
Do You Yahoo!?
Find a job, post your resume on Yahoo! Careers.


---------------------------------
Do You Yahoo!?
Get personalised at My Yahoo!.


---------------------------------
Do You Yahoo!?
Find a job, post your resume on Yahoo! Careers.
Mime
View raw message