cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markus Blasl <bl...@fzi.de>
Subject Get values from Postgres database
Date Thu, 12 Jun 2003 18:05:59 GMT
Hello,

i want to set up an application with a postgres database.
It's my first contact with cocoon so far, maybe someone can help.
What I did so far:
Installed  Postgres, Apache, Tomcat and Cocoon.
Everything is working fine, and I also played a little bit with the 
cocoon features.

Now I  downloaded the JDBC-Driver for Postgres and put it into cocoons 
lib dir.
then edited web.xml:

<init-param>
     <param-name>load-class</param-name>
     <param-value>
       <!-- For IBM WebSphere:
       com.ibm.servlet.classloader.Handler -->

       <!-- For Database Driver: -->
       org.hsqldb.jdbcDriver
   org.postgresql.Driver
       <!-- For parent ComponentManager sample:
       org.apache.cocoon.samples.parentcm.Configurator
       -->
     </param-value>
   </init-param>

And I also edited cocoon.xconf:

<datasources>
   <jdbc name="films">
     <pool-controller min="5" max="10"/>
   <dburl>jdbc:postgresql:test://localhost:5432</dburl>
     <user>blasl</user>
     <password/>
   </jdbc>
 </datasources>

If i put there something other then test (my database) thn on tty0 comes 
up DATABASE ... not found. So I guess that everything is set up ok so far.

Now I created a new directory under mount and put an xml-file in there:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:sql="http://apache.org/cocoon/SQL/v2"
 >
<page>
 <sql:connection>
   <sql:pool>films</sql:pool>
   <transactions>
     <sql:execute-query>
     <sql:query>
       select * from films
     </sql:query>
     <sql:results>
            <sql:row-results>
              <trans>
                <id>
                  <sql:get-string column="code"/>
                </id>
        <my_title>
          <sql:get-string column="title"/>
        </my_title>
                <date1>
                  <sql:get-date column="date_prod"
                     format="dd. MMM. yyyy"/>
                </date1>
                <date2>
                  <sql:get-date column="date_in"
                     format="dd. MMM. yyyy"/>
                </date2>
                <account>
                  <sql:get-string column="kind"/>
                </account>
              </trans>
            </sql:row-results>
          </sql:results>
          <sql:no-results>
            No records found...
          </sql:no-results>
          <sql:error-results>
            SQL Exception: <sql:get-message/>
          </sql:error-results>
        </sql:execute-query>
      </transactions>
    </sql:connection>
  </page>
  </xsp:page>

I also have my own sitemap.xmap file in there:

<?xml version="1.0" encoding="iso-8859-1"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">

   <!-- use the standard components -->
   <map:components>
       <map:generators default="file"/>
       <map:transformers default="xslt"/>
       <map:readers default="resource"/>
       <map:serializers default="html"/>
       <map:selectors default="browser"/>
       <map:matchers default="wildcard"/>
   </map:components>
       <map:pipelines>
       <map:pipeline>
           <!-- respond to *.html requests with
                our docs processed by doc2html.xsl -->
           <map:match pattern="*.html">
               <map:generate src="{1}.xml"/>
               <map:transform src="doc2html.xsl"/>
               <map:serialize type="html"/>
           </map:match>
         <map:match pattern="sql/*">

    <map:transform type="sql">
    <map:parameter name="use-connection" value="films"/>
    </map:transform>
    <map:transform src="stylesheets/simple-sql2html.xsl"/>
    <map:serialize/>
   </map:match>
   </map:pipeline>
   </map:pipelines>
</map:sitemap>

This is the table of my database:
             Table "public.films"
 Column   |          Type           | Modifiers
-----------+-------------------------+-----------
code      | character(5)            | not null
title     | character varying(40)   | not null
date_prod | date                    |
date_in   | date                    |
kind      | character(15)           |
len       | interval hour to minute |
Indexes: firstkey primary key btree (code)



When I now try to get the html-output of the xml file, all i get is this:

films select * from films No records found... SQL Exception:


Please, if anyone has an idea how to fix  it, I'd really be happy.

Thanks in advance,

Markus




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