You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ferran Urgell <ur...@yahoo.com> on 2001/11/05 08:39:24 UTC

Trying to connect mysql to cocoon2

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.

RE: Trying to connect mysql to cocoon2

Posted by Jeremy Aston <je...@yahoo.co.uk>.
Hi Feran,

If I understand you correctly then everything should be working as your
previous mails suggest everything is configured correctly.

To use the connection you will need an XSP page that incorporates ESQL code
similar to below.  The XSP can have the ESQL stuff in it directly or you
could put it in a logicsheet to make things a little clearer.

You then need a stylesheet that will render the XSP into your delivery
format (typically HTML).

The sitemap is configured as a basic XSP/XSL rendering process in the style
(assuming the names dbtest.xsp and dbtest.xsl):

  <map:match pattern="dbtest.html">
  <map:generate type="serverpages" src="dbtest"/>
    <map:transform type="xslt" src="dbtest.xsl"/>
  <map:serialize/>
  </map:match>

You can then call dbtest.html and it should work.

HTH

Jeremy
  -----Original Message-----
  From: Ferran Urgell [mailto:urgsimfe@yahoo.com]
  Sent: 07 November 2001 07:38
  To: cocoon-users@xml.apache.org; jez@pigbite.com
  Subject: Re: Trying to connect mysql to cocoon2


  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 <je...@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 <ur...@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.

RE: Trying to connect mysql to cocoon2 (more)

Posted by Ferran Urgell <ur...@yahoo.com>.
 I'm recieving this error in cocoon.log
  EBUG   (2001-11-09) 06:33.34:912   [cocoon  ] (/cocoon/sql/sql-page) HttpProcessor[8080][3]/SQLTransformer$Query: SQLTransformer$Query: could not acquire a Connection -- waiting 0 ms to try again.
DEBUG   (2001-11-09) 06:33.34:913   [cocoon  ] (/cocoon/sql/sql-page) HttpProcessor[8080][8]/SQLTransformer$Query: SQLTransformer$Query: could not acquire a Connection -- waiting 0 ms to try again.
DEBUG   (2001-11-09) 06:33.34:913   [cocoon  ] (/cocoon/sql/sql-page) HttpProcessor[8080][7]/SQLTransformer$Query: SQLTransformer$Query: could not acquire a Connection -- waiting 0 ms to try again.
DEBUG   (2001-11-09) 06:33.34:914   [cocoon  ] (/cocoon/sql/sql-page) HttpProcessor[8080][5]/SQLTransformer$Query: SQLTransformer$Query: could not acquire a Connection -- waiting 0 ms to try again.
DEBUG   (2001-11-09) 06:33.34:915   [cocoon  ] (/cocoon/sql/sql-page) HttpProcessor[8080][9]/SQLTransformer$Query: SQLTransformer$Query: could not acquire a Connection -- waiting 0 ms to try again.
DEBUG   (2001-11-09) 06:33.34:916   [cocoon  ] (/cocoon/sql/sql-page) HttpProcessor[8080][4]/SQLTransformer$Query: SQLTransformer$Query: could not acquire a Connection -- waiting 0 ms to try again.
DEBUG   (2001-11-09) 06:33.34:916   [cocoon  ] (/cocoon/sql/sql-page) HttpProcessor[8080][0]/SQLTransformer$Query: SQLTransformer$Query: could not acquire a Connection -- waiting 0 ms to try again.
DEBUG   (2001-11-09) 06:33.34:916   [cocoon  ] (/cocoon/sql/sql-page) HttpProcessor[8080][6]/SQLTransformer$Query: SQLTransformer$Query: could not acquire a Connection -- waiting 0 ms to try again.
DEBUG   (2001-11-09) 06:33.34:917   [cocoon  ] (/cocoon/sql/sql-page) HttpProcessor[8080][2]/SQLTransformer$Query: SQLTransformer$Query: could not acquire a Connection -- waiting 0 ms to try again.
DEBUG   (2001-11-09) 06:33.34:918   [cocoon  ] (/cocoon/sql/sql-page) HttpProcessor[8080][1]/SQLTransform



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

RE: Trying to connect mysql to cocoon2 (more)

Posted by David Rosenstrauch <da...@dti.net>.
I think you need to check the cocoon.log file, cause it doesn't look like the cause of the error is getting written to the screen.  (FYI - it sounded from someone's post yesterday like cocoon 2 rc2 fixes that issue, i.e., writes the entire exception chain to the screen.)


DR


At 02:28 AM 11/8/01 -0800, you wrote:

>I'm trying to get somtehing via Mysql and not works.... 
>
>This is my sitemap.... 
>
><map:match pattern="sql/prova">
>     <map:generate src="docs/samples/sql/sql.xml"/>
>    <map:transform type="sql">
>       <map:parameter name="use-connection" value="test"/>
>     </map:transform>
>     <map:transform src="stylesheets/sim.xsl"/>
>     <map:serialize/>
>    </map:match> 
>
>sql.xml 
>
><?xml version="1.0"?> 
>
><page xmlns:sql="http://apache.org/cocoon/SQL/2.0"> 
>
>  <title>Hello</title>
>  <content>
>   <para>This is my first Cocoon2 page filled with sql data!</para> 
>
>   <execute-query xmlns="http://apache.org/cocoon/SQL/2.0"> 
>    <query>
>         select id,name from department_table
>    </query>
>   </execute-query> 
>
>  </content>
></page> 
>
>sim.xsl 
>
><?xml version="1.0"?> 
>
><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>                               xmlns:sql="http://apache.org/cocoon/SQL/2.0">
>  <xsl:import href="page/simple-page2html.xsl"/>      
><xsl:output method="html" encoding="UTF-8"/>
>   <xsl:template match="/">
>   <html>
>     <xsl:apply-templates/>
>    <h1>gogogog</h1>
></hmtl>
>   </xsl:template> 
>
></xsl:stylesheet> 
>
>and not works...... 
>
>
>org.apache.cocoon.ProcessingException: Failed to execute pipeline.: java.lang.RuntimeException: Problem in getTransformer:Error in creating Transform Handler
>
>org.apache.cocoon.ProcessingException: Failed to execute pipeline.: java.lang.RuntimeException: Problem in getTransformer:Error in creating Transform Handler
>         at org.apache.cocoon.components.pipeline.CachingStreamPipeline.process(CachingStreamPipeline.java:379)
>         at org.apache.cocoon.www.sitemap_xmap.wildcardMatchN400452(sitemap_xmap.java:5861)
>         at org.apache.cocoon.www.sitemap_xmap.process(sitemap_xmap.java:2579)
>         at org.apache.cocoon.www.sitemap_xmap.process(sitemap_xmap.java:2181)
>         at org.apache.cocoon.sitemap.Handler.process(Handler.java:163)
>         at org.apache.cocoon.sitemap.Manager.invoke(Manager.java:116)
>         at org.apache.cocoon.Cocoon.process(Cocoon.java:495)
>         at org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:534)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Unknown Source)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(Unknown Source)
>         at org.apache.catalina.core.StandardWrapperValve.invoke(Unknown Source)
>         at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
>         at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
>         at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
>         at org.apache.catalina.core.StandardContextValve.invoke(Unknown Source)
>         at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
>
>
>Do You Yahoo!?
>Find a job, post your resume on <http://careers.yahoo.com/?clink=foot-fp>Yahoo! Careers. 


---------------------------------------------------------------------
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: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


RE: Trying to connect mysql to cocoon2 (more)

Posted by Ferran Urgell <ur...@yahoo.com>.
I'm trying to get somtehing via Mysql and not works....
This is my sitemap....
<map:match pattern="sql/prova">
    <map:generate src="docs/samples/sql/sql.xml"/>
   <map:transform type="sql">
      <map:parameter name="use-connection" value="test"/>
    </map:transform>
    <map:transform src="stylesheets/sim.xsl"/>
    <map:serialize/>
   </map:match>
sql.xml
<?xml version="1.0"?>
<page xmlns:sql="http://apache.org/cocoon/SQL/2.0">
 <title>Hello</title>
 <content>
  <para>This is my first Cocoon2 page filled with sql data!</para>
  <execute-query xmlns="http://apache.org/cocoon/SQL/2.0"> 
   <query>
        select id,name from department_table
   </query>
  </execute-query>
 </content>
</page>
sim.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                              xmlns:sql="http://apache.org/cocoon/SQL/2.0">
 <xsl:import href="page/simple-page2html.xsl"/>      
<xsl:output method="html" encoding="UTF-8"/>
  <xsl:template match="/">
  <html>
    <xsl:apply-templates/>
   <h1>gogogog</h1>
</hmtl>
  </xsl:template>
</xsl:stylesheet>
and not works......

org.apache.cocoon.ProcessingException: Failed to execute pipeline.: java.lang.RuntimeException: Problem in getTransformer:Error in creating Transform Handler

org.apache.cocoon.ProcessingException: Failed to execute pipeline.: java.lang.RuntimeException: Problem in getTransformer:Error in creating Transform Handler	at org.apache.cocoon.components.pipeline.CachingStreamPipeline.process(CachingStreamPipeline.java:379)	at org.apache.cocoon.www.sitemap_xmap.wildcardMatchN400452(sitemap_xmap.java:5861)	at org.apache.cocoon.www.sitemap_xmap.process(sitemap_xmap.java:2579)	at org.apache.cocoon.www.sitemap_xmap.process(sitemap_xmap.java:2181)	at org.apache.cocoon.sitemap.Handler.process(Handler.java:163)	at org.apache.cocoon.sitemap.Manager.invoke(Manager.java:116)	at org.apache.cocoon.Cocoon.process(Cocoon.java:495)	at org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:534)	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Unknown Source)	at org.apache.catalina.core.ApplicationFilterChain.doFilter(Unknown Source)	at org.apache.catalina.core.StandardWrapperValve.invoke(Unknown Source)	at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)	at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)	at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)	at org.apache.catalina.core.StandardContextValve.invoke(Unknown Source)	at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)




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

Databases and Cocoon2

Posted by Ferran Urgell <ur...@yahoo.com>.
What it means this message ?
Exception in ServerPagesGenerator.generate()detailsfromsourceorg.apache.cocoon.ProcessingExceptiondescriptionorg.apache.cocoon.ProcessingException: Exception in ServerPagesGenerator.generate(): java.lang.RuntimeException: Could not get the datasource java.lang.IllegalStateException: You cannot select a Component from a disposed ComponentSelectorextra info 
 





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


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

RE: Trying to connect mysql to cocoon2

Posted by Jeremy Aston <je...@yahoo.co.uk>.
Hi Feran,

I'm not quite sure I understand the problem but if you have set up the
connection information as below you can use the connection via ESQL in an
XSP page.  You will have an xsp page that contains the ESQL calls, either
directly or via a logicsheet.  You then transform this page with some XSL to
get your final output.  The documentation, "tutorial" examples (available as
part of the cvs code base at the moment - not on the rc1 distribution) and
cocoon welcome examples all demonstrate this.

If you are still having problems please be more explicit about them -
provide an example of exceptions, the code you are using etc.

Regards

Jeremy


  -----Original Message-----
  From: Ferran Urgell [mailto:urgsimfe@yahoo.com]
  Sent: 07 November 2001 07:38
  To: cocoon-users@xml.apache.org; jez@pigbite.com
  Subject: Re: Trying to connect mysql to cocoon2


  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 <je...@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 <ur...@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.

Re: Trying to connect mysql to cocoon2

Posted by Ferran Urgell <ur...@yahoo.com>.
 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 <je...@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 <ur...@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.

Re: Trying to connect mysql to cocoon2

Posted by Jeremy Aston <je...@yahoo.co.uk>.
 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 <ur...@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!.

AW: Trying to connect mysql to cocoon2

Posted by Adnan Zelkanovic <a....@allgaeu.net>.
I've made an example in XSP which works with Cocoon-1.8.2
The example shows how to use "esql" to handle Databases with Cocoon
My example is shows the complete structure of the mysql-databases which was
connected.
It shows also how to combine results with new queries as parameters.
Here it is:

<?xml version="1.0"?>
<!-- edited with XML Spy v3.5 (http://www.xmlspy.com) by Adnan Zelkanovic
(private) -->
<?cocoon-process type="xsp"?>
<xsp:page xmlns:xsp="http://www.apache.org/1999/XSP/Core"
xmlns:esql="http://apache.org/cocoon/SQL/v2">
 <page>
  <esql:connection>
   <esql:driver>org.gjt.mm.mysql.Driver</esql:driver>
   <esql:dburl>jdbc:mysql://localhost/</esql:dburl>
   <esql:username>root</esql:username>
   <esql:password/>
   <esql:execute-query>
    <esql:query>show databases</esql:query>
    <esql:results>
     <esql:row-results>
      <DATABASE>
       <NAME>
        <esql:get-string column="1"/>
       </NAME>
       <esql:connection>
        <esql:driver>org.gjt.mm.mysql.Driver</esql:driver>
        <esql:dburl>jdbc:mysql://localhost/</esql:dburl>
        <esql:username>root</esql:username>
        <esql:password/>
        <esql:execute-query>
         <esql:query>show tables from
           <esql:get-string ancestor="1" column="1"/>
         </esql:query>
         <esql:results>
          <esql:row-results>
           <TABLE>
            <NAME>
             <esql:get-string column="1"/>
            </NAME>
            <esql:connection>
             <esql:driver>org.gjt.mm.mysql.Driver</esql:driver>
             <esql:dburl>jdbc:mysql://localhost/</esql:dburl>
             <esql:username>root</esql:username>
             <esql:password/>
             <esql:execute-query>
              <esql:query>show fields from <esql:get-string ancestor="2"
column="1"/>.<esql:get-string ancestor="1" column="1"/>
              </esql:query>
              <esql:results>
               <esql:row-results>
                <FIELD>
                 <NAME>
                  <esql:get-string column="1"/>
                 </NAME>
                 <TYPE>
                  <esql:get-string column="2"/>
                 </TYPE>
                 <NULL>
                  <esql:get-string column="3"/>
                 </NULL>
                 <KEY>
                  <esql:get-string column="4"/>
                 </KEY>
                 <DEFAULT>
                  <esql:get-string column="5"/>
                 </DEFAULT>
                 <EXTRA>
                  <esql:get-string column="6"/>
                 </EXTRA>
                </FIELD>
               </esql:row-results>
              </esql:results>
             </esql:execute-query>
            </esql:connection>
           </TABLE>
          </esql:row-results>
         </esql:results>
        </esql:execute-query>
       </esql:connection>
      </DATABASE>
     </esql:row-results>
    </esql:results>
   </esql:execute-query>
  </esql:connection>
 </page>
</xsp:page>

IMPORTANT: This example only works with Cocoon-1.8.2 - If you want to use it
with cocoon2 you have to make some changes in the source code. But don't ask
me for it. I never made it before.
You also have to download the JDBC-Driver from www.mysql.com
Read this source code above to look which driver you have to download
exactly, because there are a few drivers on the mysql-homepage.

I know, this is not 100%ly the answer you needed. But I hope, I helped you a
little bit.