cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominic Tootell" <dominic.toot...@bbc.co.uk>
Subject RE: Database connection by cocoon 2.2
Date Fri, 06 Jun 2008 12:59:49 GMT
Inside your cocoon 2 block:


1)  inside
src/main/resources/META-INF/cocoon/avalon/custom-sitemap-compents.xconf
put:

<map:components>

 	.....

	<map:transformers>
		<map:transformer logger="sitemap.transformer.sql"
name="sql" src="org.apache.cocoon.transformation.SQLTransformer"/> 

		....

	</map:transformers>
</map:components>


2)  in the block pom.xml:

  <dependency>
      <groupId>org.apache.cocoon</groupId>
      <artifactId>cocoon-databases-impl</artifactId> 
      <version>1.0.0</version>
    </dependency>
    <dependency>
    	<groupId>oracle</groupId>
    	<artifactId>oracle-jdbc</artifactId>
    	<version>10.2.0.4</version>
    </dependency>


3)  inside src/main/resources/META-INF/cocoon/spring/datasources.xml

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

    <bean
name="org.apache.avalon.excalibur.datasource.DataSourceComponent/lastmod
"
class="org.apache.cocoon.databases.bridge.spring.avalon.SpringToAvalonDa
taSourceWrapper">
        <property name="wrappedBean">
            <bean
class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
              <property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver"/>
              <property name="url"
value="jdbc:oracle:thin:@cmcdev2007:1521:cmccis"/>
              <property name="username" value="xxxx"/>
              <property name="password" value="xxxxx"/>
            </bean>
        </property>
    </bean>
</beans>

4)  inside src/main/resources/COB-INF/sitemap.xmap:

<map:match pattern="runsql/*">
	<map:generate src="sql/sql.xml"/>
	<map:transform type="sql">
					<map:parameter
name="use-connection" value="lastmod"/>
					<map:parameter
name="show-nr-of-rows" value="true"/> 
					<map:parameter
name="clob-encoding" value="UTF-8"/>
					<map:parameter name="date"
value="{1}"/>
	</map:transform>
	<map:serialize type="xml"/>
</map:match>


5)  inside src/main/resources/COB-INF/sql/sql.xml:

<?xml version="1.0" encoding="UTF-8"?>
<page>
    <title>Hello</title>
    <content>
        <para>The following concepts were modified since:</para>
        <sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">

            <sql:query name="lastmod">
                SELECT * FROM DALCONCEPT_LASTMOD 
                WHERE LASTMODIFIED &gt;= TO_DATE('<sql:substitute-value 
                    sql:name="date"/>','YYYYMMDD')
            </sql:query>
        </sql:execute-query>
    </content>
</page>


I agree with the others though.... Hibernate + Spring should be used for
any production type app, for a quick mock up, the above should work
without having to go near Spring + Hibernate.

/dom


-----Original Message-----
From: Derek Hohls [mailto:DHohls@csir.co.za] 
Sent: 06 June 2008 13:25
To: users@cocoon.apache.org
Subject: Re: Database connection by cocoon 2.2

Johannes

Just curious - is there a pressing reason to  use 2.2?  Why not download
and work with 2.1 (which ships with the sample code you requested).
Again, IMO, 2.2 still needs more work - esp.
docs and simple examples - in making it accessible to the 
"average" user.    

Cheers
Derek

>>> On 2008/06/06 at 01:37, in message <48492181.2080406@memocomp.de>,
Johannes Hoechstaedter <j.hoechstaedter@memocomp.de> wrote:
The linked sample is nice, and basically exactly what I am looking for.

I have already searched on http://cocoon.apache.org/2.1/ on how I can
etablish a database connection. You need an entry int your web.xml and
in your cocoon.xconf for example. Where is the cocoon.xconf in 2.2? 
Where can I define my datasources? Where can I get the code of the
sample?

Johannes

Derek Hohls schrieb:
> Johannes
>  
> Good question!  The "official and best" way is to use Hibernate and 
> Spring; this will, IMO, mean writing *lots* of code. You can use 
> flowscript instead, for simple cases, but be warned that many here 
> will point out the potential flaws in this approach.
>  
> In the 2.1.x series of Cocoon, there was a sample that showed this
> approach:
> eg. see
> http://cocoon.jsp ( http://cocoon.jsp/ 
> )-servlet.net/samples/blocks/forms/
> and look for "Database access".
>  
> I am not sure if you will be able to replicate this in 2.2?
>  
> Derek
>  
> >>> On 2008/06/06 at 10:05, in message <4848EFB2.4090109@memocomp.de
> <mailto:4848EFB2.4090109@memocomp.de>>, Johannes Hoechstaedter 
> <j.hoechstaedter@memocomp.de <mailto:j.hoechstaedter@memocomp.de>>
wrote:
> Good morning Bng,
>  
> I know, cocoon is based on spring. But isn't there another possibility

> with cocoon blocks only? There is this database-block. What it is good

> for, when I have to write my own spring application? I want to write 
> as less code as possible.
>  
> Johannes
>  
> > Johannes -- you may want to search for tutorials on using databases 
> > with Spring.  My understanding is that with Cocoon 2.2 it is best to

> > have Spring configure and manage any database connections.  Then you

> > can add Cocoon features (eg, the SQL transformer or whatever) once 
> > that is set up.
> >
> > Bng
> >  
>  
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> <mailto:users-unsubscribe@cocoon.apache.org>
> For additional commands, e-mail: users-help@cocoon.apache.org 
> <mailto:users-help@cocoon.apache.org>
>
> --
> This message is subject to the CSIR's copyright terms and conditions, 
> e-mail legal notice, and implemented Open Document Format (ODF)
standard.
> The full disclaimer details can be found at 
> http://www.csir.co.za/disclaimer.html.
>
>
> This message has been scanned for viruses and dangerous content by
> *MailScanner* <http://www.mailscanner.info/>, and is believed to be 
> clean. MailScanner thanks Transtec Computers 
> <http://www.transtec.co.uk/> for their support.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org 



-- 
This message is subject to the CSIR's copyright terms and conditions,
e-mail legal notice, and implemented Open Document Format (ODF)
standard. 
The full disclaimer details can be found at
http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by
MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for
their support.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain personal views which are
not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify
the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.
					

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message