You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@forrest.apache.org by Sedziwoj <se...@epf.pl> on 2006/02/02 14:38:28 UTC

Database Plugin

Hello

I'm working on web portal in XML as my master's thesis. I used Forrest 
as tool to do it but i have problem. I need get data from MySQL 
database, but I don't know how. I dont have any experience with Cocoon 
or Java. I tried to use SQL Transformer and I failed. In mailing list I 
read then you made database plugin but i can't find them on plugin list. 
Could you tell me where I can find it and how to use it?

Best regards
Grzegorz Sulkowski
sedziwoj@epf.pl


Re: Database Plugin

Posted by Ross Gardler <rg...@apache.org>.
Sedziwoj wrote:
> Ross Gardler napisał(a):
> 
>> Just change the xconf and xweb configuration (in the conf directory) 
>> to use the mySQL driver and your database settings.
> 
> 
> This is my config modyfication:
> "cocoon-databases.xconf"

But have you included the config files so that Forrest actually uses 
them. As I mentioned early on in this thread I have not yet gotten 
around to automating this process so it needs to be done manually. This 
is why the plugin is in whiteboard.

See the relevant files xconf and web.xml files in 
FORREST_HOME/main/webapp/WEB-INF

Ross



Re: Database Plugin

Posted by Sedziwoj <se...@epf.pl>.
Ross Gardler napisał(a):

> Just change the xconf and xweb configuration (in the conf directory) to 
> use the mySQL driver and your database settings.

This is my config modyfication:
"cocoon-databases.xconf"

<components>
  <include 
src="resource://org/apache/cocoon/components/database/database.roles"/>

   <datasources>
     <jdbc name="telefony">
       <pool-controller min="5" max="10"/> 
<dburl>jdbc:mysql://localhost:3306/telefony?autoReconnect=true</dburl>
       <user>MyUser</user>
       <password>MyPassword</password>
     </jdbc>
   </datasources>
   </components>

"hsql.driver.xweb"

<xweb 
xpath="/web-app/servlet/init-param[param-name='load-class']/param-value"
	unless="text()[contains(string(.),'com.mysql.jdbc.Driver')] |
		comment()[contains(string(.),'com.mysql.jdbc.Driver')]">
         <!-- For Database Driver: -->
         com.mysql.jdbc.Driver

</xweb>

"input.xmap"

<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
   <map:components>
	<map:transformers default="xslt">
	  <map:transformer name="sql" 
src="org.apache.cocoon.transformation.SQLTransformer"/>
	</map:transformers>
   </map:components>

   <map:pipelines>
	  <map:pipeline>
	   <map:match pattern="ks_tel.xml">
	    <map:generate src="{project:content.xdocs}/kt/ks_tel.xml"/>
		<map:transform type="sql">
	  	  <map:parameter name="dburl" 
value="jdbc:mysql://localhost:3306/telefony?autoReconnect=true"/>
	      <map:parameter name="username" value="MyUser"/>
		  <map:parameter name="password" value="MyPassword"/>
		  <map:parameter name="show-nr-of-rows" value="true"/>
		</map:transform>
		<map:transform src="resources/stylesheets/sqldata2table.xsl"/>
	    <map:serialize type="xml"/>
	   </map:match>
	  </map:pipeline>
    </map:pipelines>

</map:sitemap>

"web.xml"
...
<init-param>
       <param-name>load-class</param-name>
       <param-value>com.mysql.jdbc.Driver
       </param-value>
     </init-param>
...

My XML file:
"ks_tel.xml"

<document>
	<header>
		<title>Telefony</title>
	</header>
	<body>
		<section>
			<title>Sortuj</title>
   <sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
     <sql:use-connection>telefony</sql:use-connection>
     <sql:query>
       select * from telefony;
     </sql:query>
   </sql:execute-query>
	</section>
	</body>
</document>

Forrest even not trying connect to DB server (I checked this in server 
logs). I don't know what is wrong. Can you help me? I dont know Java 
lang. or Cocoon.

> The plugin is only a slightly modified version of the Cocoon Database 
> block, the documentation for the Cocoon Block is still relevant.

I checked this documentation, description of SQL Transformer, articles 
in Cocoon Wiki about database connection and "A User's Look at the 
Cocoon Architecture By Matthew Langham, Carsten Ziegeler" - description 
of Cocoon-database connection. I still don't know when I do wrong. Can 
you help me?

Thank you
Greg


Re: Database Plugin

Posted by Ross Gardler <rg...@apache.org>.
Sedziwoj wrote:
> Thanks for answer
> 
> Could you tell me how I must modify plugin's files to work with MySQL 
> database? I need mysql-connector-java or something like this, right? 
> Your plugin only has excalibur and hsqldb driver. Am I right?

Just change the xconf and xweb configuration (in the conf directory) to 
use the mySQL driver and your database settings.

The plugin is only a slightly modified version of the Cocoon Database 
block, the documentation for the Cocoon Block is still relevant.

Ross

Re: Database Plugin

Posted by Sedziwoj <se...@epf.pl>.
Thanks for answer

Could you tell me how I must modify plugin's files to work with MySQL 
database? I need mysql-connector-java or something like this, right? 
Your plugin only has excalibur and hsqldb driver. Am I right?


Greg


Re: Database Plugin

Posted by Ross Gardler <rg...@apache.org>.
Gav.... wrote:
> Hi G , :)
> 
> It 'looks' like you would need to get the plugin from
> ..\whiteboard\plugins\org.apache.forrest.plugin.Database
> 
> This is a whiteboard plugin, usually meaning 'use at your own risk'
> Sometimes though only popular plugins make it out of the 
> whiteboard, so unpopular ones remain there even if stable.
> 
> Strange though how I could not find it listed on the 
> plugins section of the forrest site 
> http://forrest.apache.org/pluginDocs/plugins_0_80/index.html

It has never been released because forrest.xconf needs to be patched for 
it to know where to get database connection from.

At one time I patched Forrest to allow automatic patching of the xconf 
files when plugins are installed. However, I used the XPatch method 
which is being deprecated within Cocoon, so we removed it again.

I have half-enabled the ability to dynamically load additional xconf 
files. However, I never found the time to finish off this work. Perhaps, 
now we have a user needing it, we will finish it with their help ;-)

There is also a need to patch the web.xml file, currently there is no 
way of doing this automatically.

However, both of these can be done by hand (see Cocoon docs on this).

> Maybe it is only available via subversion. You may need to
> use the latest svn version of forrest, or someone else
> will be along to tell you how you can get it elsewhere.

It is only available via SVN.

It should work with 0.7, but I make no promises about that, best to use 
SVN head.

An alternative, which I am using right now, is to write a custom 
generator that will talk directly to the database. This is not the most 
efficient method as it will no reuse the database pooling etc. within 
the Cocoon DB block, however, it is quick and easy to do (if you know 
how to write a java app to talk to the DB).

I can provide some simple skeleton code as an example if you want to go 
this later route.

Ross

Re: Database Plugin

Posted by "Gav...." <br...@brightontown.com.au>.
Hi G , :)

It 'looks' like you would need to get the plugin from
..\whiteboard\plugins\org.apache.forrest.plugin.Database

This is a whiteboard plugin, usually meaning 'use at your own risk'
Sometimes though only popular plugins make it out of the 
whiteboard, so unpopular ones remain there even if stable.

Strange though how I could not find it listed on the 
plugins section of the forrest site 
http://forrest.apache.org/pluginDocs/plugins_0_80/index.html

Maybe it is only available via subversion. You may need to
use the latest svn version of forrest, or someone else
will be along to tell you how you can get it elsewhere.

Gav...


----- Original Message ----- 
From: "Sedziwoj" <se...@epf.pl>
To: <us...@forrest.apache.org>
Sent: Thursday, February 02, 2006 9:38 PM
Subject: Database Plugin


| Hello
| 
| I'm working on web portal in XML as my master's thesis. I used Forrest 
| as tool to do it but i have problem. I need get data from MySQL 
| database, but I don't know how. I dont have any experience with Cocoon 
| or Java. I tried to use SQL Transformer and I failed. In mailing list I 
| read then you made database plugin but i can't find them on plugin list. 
| Could you tell me where I can find it and how to use it?
| 
| Best regards
| Grzegorz Sulkowski
| sedziwoj@epf.pl
| 
| 
| 
| -- 
| No virus found in this incoming message.
| Checked by AVG Free Edition.
| Version: 7.1.375 / Virus Database: 267.15.0/248 - Release Date: 1/02/2006
| 
|


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.0/248 - Release Date: 1/02/2006