You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Friedrich <ft...@frontwire.com> on 2001/03/29 11:08:36 UTC
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: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: Getting Cocoon to talk to a mysql database
Posted by Friedrich <ft...@frontwire.com>.
Thanks alot, that is very helpful, unfortunatly I have been real busy so I
have not tried it yet but just to let you know I appreciate your response.
Thanks, Friedrich
On Thu, Mar 29, 2001 at 11:33:59AM +0200, Georg Schmitt wrote:
> 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" <ft...@frontwire.com>
> To: <co...@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: <co...@xml.apache.org>
> > For additional commands, e-mail: <co...@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: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@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: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: Getting Cocoon to talk to a mysql database
Posted by Georg Schmitt <ap...@georg-schmitt.de>.
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" <ft...@frontwire.com>
To: <co...@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: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@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: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
SV: Getting Cocoon to talk to a mysql database
Posted by Pal Wester <pa...@florence.never.no>.
esql is not made for one particular database.
when using mysql, you have to have a jdbc
driver for mysql. I use mm.mysql jdbcdriver
you'll find more info here:
http://www.mysql.com/downloads/api-jdbc.html
Assuming you use mm.mysql you have to change
the driver in the examples. the line would look
somthing like this:
<esql:driver>org.gjt.mm.mysql.Driver</esql:driver>
Or use conectionpooling. You set it up in
your cocoon.properties file:
processor.xsp.pool.database.poolname.driver=org.gjt.mm.mysql.Driver
processor.xsp.pool.database.poolname.url=jdbc:mysql://localhost:3306/mydatab
ase
processor.xsp.pool.database.poolname.username=myusername
processor.xsp.pool.database.poolname.password=mypasswd
processor.xsp.pool.database.poolname.maxConnections=15
processor.xsp.pool.database.poolname.expiryTime=3600000
then instead of the <esql:driver,user,dburl,password/> u
only have to use <esql:pool>poolname</esql:pool>
enjoy :o)
mvh: Pal Wester <ma...@never.no>
hogskoleingenor/programmerer
> -----Opprinnelig melding-----
> Fra: Friedrich [mailto:ftc@frontwire.com]
> Sendt: 29. mars 2001 11:09
> Til: cocoon-users@xml.apache.org
> Emne: 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: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@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: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>