cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Georg Schmitt" <apa...@georg-schmitt.de>
Subject Re: Getting Cocoon to talk to a mysql database
Date Thu, 29 Mar 2001 09:33:59 GMT
Hello Friedrich,

try this:
- download the latest jdbc driver from http://mmmysql.sourceforge.net/
- copy this dirver into tomcat/lib directory and add it to Classpath
Variable
- in this example you need a database on mysql server named "testdb" and a
table "test" with columns "ID" and "Name" (with some data in the table, so
that you can see something)
- try default user: "monty"; passwort: "" for access to mysql database
- replace the ip 192.168.1.1 with your mysql server ip adress
XML file:
<?xml version="1.0"?>

<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet type="text/xsl" href="esql.xsl"?>

<xsp:page
 language="java"
 xmlns:sql="http://www.apache.org/1999/SQL"
 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://192.186.1.1/testdb</esql:dburl>
  <esql:username>monty</esql:username>
  <esql:password></esql:password>
  <esql:execute-query>
    <esql:query>select id,name from test</esql:query>
    <esql:results>
      <header>header info</header>
      <esql:row-results>
        <department>
          <id><esql:get-int column="id"/></id>
          <name><esql:get-string column="name"/></name>

        </department>
      </esql:row-results>
      <footer>footer info</footer>
    </esql:results>
  </esql:execute-query>
</esql:connection>

XSL file: esql.xsl
<?xml version="1.0"?>

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xsp="http://www.apache.org/1999/XSP/Core"
  xmlns:esql="http://apache.org/cocoon/SQL/v2"
  version="1.0"
>

<xsl:template match="/page">
  <html>
    <head>
      <title>Apache Cocoon - esql sample page</title>
    </head>
    <body>
      <p>
        <xsl:value-of select="header"/>
      </p>
      <table border="1">
        <xsl:for-each select="department">
          <tr>
            <td>
              <xsl:value-of select="id"/>
            </td>
            <td>
              <xsl:value-of select="name"/>
            </td>
          </tr>
        </xsl:for-each>
      </table>
      <p>
        <xsl:value-of select="footer"/>
      </p>
    </body>
  </html>
</xsl:template>

</xsl:stylesheet>




----- Original Message -----
From: "Friedrich" <ftc@frontwire.com>
To: <cocoon-users@xml.apache.org>
Sent: Thursday, March 29, 2001 11:08 AM
Subject: Getting Cocoon to talk to a mysql database


> Greetings all,
>
> Is there anywhere I can find some more documentation on the esql package?
I
> would like to query a mysql database but the example seems to do
postgresql.
> What I would like to do is get information from a mysql database and use
> that info in my xml documents.
>
> My apologies that this a very vague question but is there a resource
somewhere
> where I can get details on getting cocoon to talk to a mysql database.
Basically
> I just need something to get me started with using databases with xml.
>
> Possibly I just need to do more research into how xml works in general but
any
> help in this regard would be much appreciated.
>
> Regards, Friedrich
>
> ---------------------------------------------------------------------
> 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>
>


---------------------------------------------------------------------
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