You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by David Rosenstrauch <da...@dti.net> on 2001/12/26 18:28:53 UTC

Re: Cocoon2 & mySQL database update query with success/failure differentiation

Try using:

<esql:error-results>
     <esql:get-message/>
</esql:error-results>


DR



At 05:42 PM 12/26/01 +0100, you wrote:
>Hello everybody,
>
>I have the following problem and for me it is hard to tell where the reasons are:
>
>I am trying to send an insert query to mySQL from an XSP-Page processed  by
>Cocoon 2.
>
>If successful the resultpage shall yield some hopebringing comment, for
>example which values have been inserted.
>
>If the update fails (because of a SQLException) I need to tell it to the user.
>
>Therefore I have tried to use the <esql:results> and <esql:no-results> tags
>from the esql-taglib (this once worked fine with Cocoon 1 and Oracle 8). But
>with mySQL and Cocoon 2 it just won't work. Either I get always only success
>messages even if the query fails, or no text at all.
>
>Has anybody experiences with this or knows an answer that could help?
>
>Thanks,
>Uwe Stelzer
>
>
>Here is the source of my XSP page:
>
>--------------------------------------------------------------------------------------
>
><?xml version="1.0" encoding="UTF-8"?>
>
><xsp:page
>     language="java"
>     xmlns:xsp="http://apache.org/xsp"
>     xmlns:esql="http://apache.org/cocoon/SQL/v2"
>     xmlns:request="http://www.apache.org/1999/XSP/Request"
>     xmlns:util="http://www.apache.org/1999/XSP/Util"
> >
>
><xsp:structure>
>         <xsp:include>java.lang.*</xsp:include>
></xsp:structure>
>
><page>
>  
>     <xsp:logic>
>         String something = request.getParameterValues("something")[0];
>     //... maybe some more variables
>     </xsp:logic>
>
><esql:connection>
>   <esql:driver>org.gjt.mm.mysql.Driver</esql:driver>
>   <esql:dburl>jdbc:mysql://localhost:3306/myDatabase?user=myUser</esql:dburl>
>
>   <esql:execute-query>
>   <esql:query>
>     insert into StudentTable (something)
>     VALUES ('<xsp:expr>something</xsp:expr>')
>   </esql:query>
>
>   <esql:results>
>     <esql:update-results>
>         <success>
>             <something>
>                 <xsp:expr>something</xsp:expr>
>             </something>
>         </success>
>     </esql:update-results>
>   </esql:results>
>   
>     <esql:no-results>
>         <fail>
>             <something>
>                 Oooops, database update query failed!
>             </something>
>         </fail>
>     </esql:no-results>
>
>  </esql:execute-query> 
>
></esql:connection>
>
></page>
></xsp:page>
>
>--------------------------------------------------------------------------------------
>
>
>
>---------------------------------------------------------------------
>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>


User authentication [was Re: Cocoon2 & mySQL database ...]

Posted by Arnaud Vandyck <ar...@ulg.ac.be>.
"Uwe Stelzer" <Uw...@web.de> wrote:

> Now I only need a good user authentification against the database.

You have  an example "Session XSP  - Sample Session  XSP to illustrate
session handling." on the demo of Cocoon. You also have the "Protected
Area  -  An  example  web-application built  around  db-authenticator,
form-validator, session-validator and session-invalidator actions."

These two examples should be enough to start. 

Have fun,

-- Arnaud, STE-Formations Informatiques, fapse, ULg, .BE

---------------------------------------------------------------------
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: Cocoon2 & mySQL database update query with success/failure differentiation

Posted by Uwe Stelzer <Uw...@web.de>.
Thanks to David,

really, that was helpful! I also found out that I have to remove <esql:results>.
Then everything works fine.

I was near to cancelling the use of cocoon and mySQL for my project.

Now I only need a good user authentification against the database.
I'm planning to create sessions in Cocoon2/Tomcat4 and use session
variables to store user login information and then construct the <esql:dburl>
from these values. Is this a good idea? Any comments?

Uwe Stelzer


----- Original Message ----- 
From: "David Rosenstrauch" <da...@dti.net>
To: <co...@xml.apache.org>
Sent: Wednesday, December 26, 2001 6:28 PM
Subject: Re: Cocoon2 & mySQL database update query with success/failure differentiation


> Try using:
> 
> <esql:error-results>
>      <esql:get-message/>
> </esql:error-results>
> 
> 
> DR
> 
> 
> 
> At 05:42 PM 12/26/01 +0100, you wrote:
> >Hello everybody,
> >
> >I have the following problem and for me it is hard to tell where the reasons are:
> >
> >I am trying to send an insert query to mySQL from an XSP-Page processed  by
> >Cocoon 2.
> >
> >If successful the resultpage shall yield some hopebringing comment, for
> >example which values have been inserted.
> >
> >If the update fails (because of a SQLException) I need to tell it to the user.
> >
> >Therefore I have tried to use the <esql:results> and <esql:no-results> tags
> >from the esql-taglib (this once worked fine with Cocoon 1 and Oracle 8). But
> >with mySQL and Cocoon 2 it just won't work. Either I get always only success
> >messages even if the query fails, or no text at all.
> >
> >Has anybody experiences with this or knows an answer that could help?
> >
> >Thanks,
> >Uwe Stelzer
> >
> >
> >Here is the source of my XSP page:
> >
------------ snip --------------


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