OK,

I tried to implement your example, but can't get the connection pooling to
work (I guess). It _works_ when I _don't_ use pooling, so I can't understand
what's wrong. The driver is mm.mysql 2.0.4 and is located in
TOMCAT_HOME/lib.

Below is the error message and cocoon.properties:

---------------------------------------

Error found handling the request.
java.lang.RuntimeException: Error opening pooled connection: annemarie:
Database type org.gjt.mm.mysql.Driver not implemented.
        at
_var._tomcat._webapps._cocoon._vt._sec_sql._sec_sql.populateDocument(_sec_sq
l.java:195)
        at
org.apache.cocoon.processor.xsp.XSPPage.getDocument(XSPPage.java:97)
        at
org.apache.cocoon.processor.xsp.XSPProcessor.process(XSPProcessor.java:527)
        at org.apache.cocoon.Engine.handle(Engine.java:384)
        at org.apache.cocoon.Cocoon.service(Cocoon.java:183)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
        at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
        at org.apache.tomcat.core.Handler.service(Handler.java:287)
        at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
        at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
        at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
(Ajp12ConnectionHandler.java:166)
        at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
        at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
        at java.lang.Thread.run(Thread.java:484)

------------------

>From my cocoon.properties:

------------------------

# Turbine DB Connection Pool
############################

# These are your database settings, look in the
# org.apache.turbine.util.db.pool.* package for more information.

# Inserted 01-08-2001:
processor.xsp.pool.database.annemarie.driver=org.gjt.mm.mysql.Driver
processor.xsp.pool.database.annemarie.url=jdbc:mysql://(my host
name)/annemarie
processor.xsp.pool.database.annemarie.username=(my username)
processor.xsp.pool.database.annemarie.password=(my password)
processor.xsp.pool.database.annemarie.maxConnections=5
processor.xsp.pool.database.annemarie.expiryTime=3600000

processor.xsp.pool.database.default.driver=oracle.jdbc.driver.OracleDriver
processor.xsp.pool.database.default.url=jdbc:oracle:thin:@localhost:1521:ORC
L
processor.xsp.pool.database.default.username=dbUser
processor.xsp.pool.database.default.password=dbPass
processor.xsp.pool.database.default.maxConnections=3
processor.xsp.pool.database.default.expiryTime=3600000

# These are the supported jdbc-drivers and their adaptors.
# These properties are used by the DBFactory.

#Inserted 01-08-2001:
processor.xsp.pool.database.adaptor=DBMM
processor.xsp.pool.database.adaptor.DBMM=org.gjt.mm.mysql.Driver

processor.xsp.pool.database.adaptor=DBWeblogic,DBOracle,DBInstantDB,DBPostgr
es,DBSybase,DBInformix,DBMySQL
processor.xsp.pool.database.adaptor.DBWeblogic=weblogic.jdbc.pool.Driver
processor.xsp.pool.database.adaptor.DBOracle=oracle.jdbc.driver.OracleDriver
processor.xsp.pool.database.adaptor.DBInstantDB=org.enhydra.instantdb.jdbc.i
dbDriver
processor.xsp.pool.database.adaptor.DBPostgres=postgresql.Driver
processor.xsp.pool.database.adaptor.DBInformix=com.informix.jdbc.IfxDriver
processor.xsp.pool.database.adaptor.DBSybase=com.sybase.jdbc.SybDriver
processor.xsp.pool.database.adaptor.DBMySQL=org.gjt.mm.mysql.Driver

--------------------

What could be missing?

/Anne Marie


-----Original Message-----
From: JEULIN Olivier [mailto:[EMAIL PROTECTED]]
Sent: 31. juli 2001 13:26
To: '[EMAIL PROTECTED]'
Subject: RE: Connecting database and XML pages


As usual here, you forgot to tell which version of cocoon you're using...
Here is an (short!) example of what you can do with C1.8.2 (it may slightly
differ with C2):

<xsp:page
xmlns:xsp="http://www.apache.org/1999/XSP/Core";
xmlns:auth="http://ulim.cocoonhost.com/auth";
xmlns:request="http://www.apache.org/1999/XSP/Request";
xmlns:session="http://www.apache.org/1999/XSP/Session";
xmlns:foo="http://localhost/foo";
xmlns:esql="http://apache.org/cocoon/SQL/v2";
xmlns:util="http://www.apache.org/1999/XSP/Util";
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xinclude="http://www.w3.org/1999/XML/xinclude";
>

[...]

<esql:connection>
        <esql:pool>foo</esql:pool> <!-- which DB ? --> 

        <esql:execute-query>
          <esql:query>
                select b.ref as ref b.quantite as nb
                from basket b
                where b.id = <request:get-parameter name="fragResultID"/>
<!-- using a HTTP req. param. -->
          </esql:query>
        
          <esql:results>
             <esql:row-results> <!-- repeated for each row in the result set
-->
                <foo:basket>
                        <foo:item-ref><esql:get-string
column="ref"/></foo:item-ref>
                        <foo:item-nb><esql:get-int
column="nb"/></foo:item-nb>
                </foo:basket>
             </esql:row-results>
          </esql:results>

          <esql:no-results> <!-- if we don't get anything -->
                <!-- whatever -->
          </esql:no-results>

        </esql:execute-query>
</esql:connection>

[more ...]
</xsp:page>

You can retrieve different kind of data, even XML (read the doc, and
esql.xsd in the samples/sql directory)

##########################################################

You can connect directly to the DB (with user ID & pwd) or, much better,
using a connection pool.
Here is mine (from cocoon.properties), using a DB named foo:

# Turbine DB Connection Pool
############################

# These are your database settings, look in the
# org.apache.turbine.util.db.pool.* package for more information.

processor.xsp.pool.database.foo.driver=org.gjt.mm.mysql.Driver
processor.xsp.pool.database.foo.url=jdbc:mysql://your.mysql.server/foo
processor.xsp.pool.database.foo.username=foouser
processor.xsp.pool.database.foo.password=foopwd
processor.xsp.pool.database.foo.maxConnections=5
processor.xsp.pool.database.foo.expiryTime=3600000
[...]
# These are the supported jdbc-drivers and their adaptors.
# These properties are used by the DBFactory.
processor.xsp.pool.database.adaptor=DBMM
processor.xsp.pool.database.adaptor.DBMM=org.gjt.mm.mysql.Driver

You will need the JDBC adaptater for mysql (see the official mysql site,
sun's JDBC section, or search the list's archives about it)

HTH,
Olivier

> -----Message d'origine-----
> De : [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]
> Envoyé : mardi 31 juillet 2001 09:08
> À : [EMAIL PROTECTED]
> Objet : Connecting database and XML pages
> 
> 
> Hi,
> 
> I have a mySQL database. I also have a web server: 
> Apache-Tomcat-Cocoon. I
> want to make web pages written in XML, transformed to HTML or 
> WML by the
> help of Cocoon. These pages will serve as an interface to the 
> database.
> 
> What is the best way to connect the database with the XML 
> pages? My users
> should be able to read and write in the database.
> 
> Any tips, suggestions, experiences and examples are greatly 
> appreciated!
> 
> /Anne Marie

---------------------------------------------------------------------
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: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

---------------------------------------------------------------------
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: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to