You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jon Brisbin <br...@ipa.net> on 2001/02/24 07:49:19 UTC

Probs with INSERT and esql

I'm having a beast of a time getting esql's INSERT functionality to work as
expected.  Truth be told, I'm not sure where the exact error is because
Cocoon isn't very descriptive in the traceback...here's the setup:

Cocoon 1.8.2
JDK 1.3
Apache 1.3.14/mod_jserv.so

I've tried to generate a dynamic INSERT statement about 27 different ways,
but am completely unsuccessful so far...I need to use
<request:get-parameter> whether there is a form value posted or not, but I'm
not positive that when I use the esql conventions for SQL parameters, that
it's not causing the NullPointerException...I tried scrapping that and
copying the JSP code I use to do the exact same thing, but I get a really
funky error:

java.lang.Exception: XSP Java Compiler: Compilation failed for
_member_profile_insert.java
176: ')' expected.
                    StringBuffer sql = new StringBuffer("insert into
new_address values(");
                                ^
1 error


	at
org.apache.cocoon.processor.xsp.language.java.XSPJavaProcessor.compile(XSPJa
vaProcessor.java:146)
	at
org.apache.cocoon.processor.xsp.XSPProcessor.process(XSPProcessor.java:522)
	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:853)
	at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
	at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
(Ajp12ConnectionHandler.java:156)
	at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
)
	at java.lang.Thread.run(Thread.java:484)


Please help if you have any ideas whatsoever! :-)

Jon Brisbin
www.jbrisbin.net


Re: Probs with INSERT and esql

Posted by Pae Choi <pa...@earthlink.net>.
----- Original Message -----
From: "Jon Brisbin" <br...@ipa.net>
To: <co...@xml.apache.org>
Sent: Friday, February 23, 2001 10:49 PM
Subject: Probs with INSERT and esql


> I'm having a beast of a time getting esql's INSERT functionality to work
as
> expected.  Truth be told, I'm not sure where the exact error is because
> Cocoon isn't very descriptive in the traceback...here's the setup:
>
> Cocoon 1.8.2
> JDK 1.3
> Apache 1.3.14/mod_jserv.so
>
> I've tried to generate a dynamic INSERT statement about 27 different ways,
> but am completely unsuccessful so far...I need to use
> <request:get-parameter> whether there is a form value posted or not, but
I'm
> not positive that when I use the esql conventions for SQL parameters, that
> it's not causing the NullPointerException...I tried scrapping that and
> copying the JSP code I use to do the exact same thing, but I get a really
> funky error:
>
> java.lang.Exception: XSP Java Compiler: Compilation failed for
> _member_profile_insert.java
> 176: ')' expected.
>                     StringBuffer sql = new StringBuffer("insert into
> new_address values(");
>                                 ^

It showing you an error where it is coming from. Look little more careful.


> 1 error
>
>
> at
>
org.apache.cocoon.processor.xsp.language.java.XSPJavaProcessor.compile(XSPJa
> vaProcessor.java:146)
> at
>
org.apache.cocoon.processor.xsp.XSPProcessor.process(XSPProcessor.java:522)
> 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:853)
> at
>
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
> at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
> at
>
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
> (Ajp12ConnectionHandler.java:156)
> at
>
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
> )
> at java.lang.Thread.run(Thread.java:484)
>
>
> Please help if you have any ideas whatsoever! :-)
>
> Jon Brisbin
> www.jbrisbin.net
>
>
> ---------------------------------------------------------------------
> 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: Probs with INSERT and esql

Posted by Jon Brisbin <br...@ipa.net>.
i tried that several different times and ways and absolutely nothing
worked...i'm just using c1.8.2/mysql 3.22.32/mm.mysql2 and the insert would
never execute...i would get NullPointerException's doing it the below way if
there was nothing in the form field (i assume that's what caused it, not
sure though)...the plain java code is directly from a jsp page i had been
using previously...

the solution i came up with is terrible!  i'm using the old jsp page (which
just inserts and does a redirect) to insert the data into the database...i
don't like this and would prefer to have it all xml...

jb

-----Original Message-----
From: Matthew Cordes [mailto:mcorde61@maine.edu]
Sent: Saturday, February 24, 2001 11:42 AM
To: cocoon-users@xml.apache.org
Subject: Re: Probs with INSERT and esql


Hi,
I'm a little confused by your method, instead of:

> <esql:execute-query>
>     <esql:query>
>         <xsp:logic>
>             StringBuffer sql = new StringBuffer("insert into new_address
> values(");
>             sql.append(" '").append(request.getParameter("member_id"));
> ...
>             System.err.println(sql.toString());
>             <xsp:expr>sql.toString()</xsp:expr>
>         </xsp:logic>
>     </esql:query>

why not do:

<esql:query>
    insert into new_address values (
        <esql:parameter><request:get-parameter
name="member_id"/></esql:parameter> )
</esql:query>

Hope this helps.

-matt
----- Original Message -----
From: "Jon Brisbin" <br...@ipa.net>
To: <co...@xml.apache.org>; "Paul Russell" <pr...@apache.org>
Sent: Saturday, February 24, 2001 9:33 AM
Subject: RE: Probs with INSERT and esql


>
>
> >* Jon Brisbin (brisbin@ipa.net) wrote :
> >> java.lang.Exception: XSP Java Compiler: Compilation failed for
> >> _member_profile_insert.java
> >> 176: ')' expected.
> >>                     StringBuffer sql = new StringBuffer("insert into
> >> new_address values(");
> >>                                 ^
> >> 1 error
>
> >Looks like it could be a bug. Can you provide us with the fragment of
> >XML that caused it?
>
> <esql:execute-query>
>     <esql:query>
>         <xsp:logic>
>             StringBuffer sql = new StringBuffer("insert into new_address
> values(");
>             sql.append(" '").append(request.getParameter("member_id"));
> ...
>             System.err.println(sql.toString());
>             <xsp:expr>sql.toString()</xsp:expr>
>         </xsp:logic>
>     </esql:query>
>     ...
>
> Thanks!
>
> Jon Brisbin
> www.jbrisbin.net
>
>
> ---------------------------------------------------------------------
> 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>


Re: Probs with INSERT and esql

Posted by Matthew Cordes <mc...@maine.edu>.
Hi,
I'm a little confused by your method, instead of:

> <esql:execute-query>
>     <esql:query>
>         <xsp:logic>
>             StringBuffer sql = new StringBuffer("insert into new_address
> values(");
>             sql.append(" '").append(request.getParameter("member_id"));
> ...
>             System.err.println(sql.toString());
>             <xsp:expr>sql.toString()</xsp:expr>
>         </xsp:logic>
>     </esql:query>

why not do:

<esql:query>
    insert into new_address values (
        <esql:parameter><request:get-parameter
name="member_id"/></esql:parameter> )
</esql:query>

Hope this helps.

-matt
----- Original Message -----
From: "Jon Brisbin" <br...@ipa.net>
To: <co...@xml.apache.org>; "Paul Russell" <pr...@apache.org>
Sent: Saturday, February 24, 2001 9:33 AM
Subject: RE: Probs with INSERT and esql


>
>
> >* Jon Brisbin (brisbin@ipa.net) wrote :
> >> java.lang.Exception: XSP Java Compiler: Compilation failed for
> >> _member_profile_insert.java
> >> 176: ')' expected.
> >>                     StringBuffer sql = new StringBuffer("insert into
> >> new_address values(");
> >>                                 ^
> >> 1 error
>
> >Looks like it could be a bug. Can you provide us with the fragment of
> >XML that caused it?
>
> <esql:execute-query>
>     <esql:query>
>         <xsp:logic>
>             StringBuffer sql = new StringBuffer("insert into new_address
> values(");
>             sql.append(" '").append(request.getParameter("member_id"));
> ...
>             System.err.println(sql.toString());
>             <xsp:expr>sql.toString()</xsp:expr>
>         </xsp:logic>
>     </esql:query>
>     ...
>
> Thanks!
>
> Jon Brisbin
> www.jbrisbin.net
>
>
> ---------------------------------------------------------------------
> 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: Probs with INSERT and esql

Posted by Paul Russell <pa...@luminas.co.uk>.
* Jon Brisbin (brisbin@ipa.net) wrote :
> i always assumed that it *does* work, when used correctly, but my original
> point was that i tried it in my own app's context...exactly how the
> documentation and the archives suggested to do it...but i was getting
> nullpointerexceptions when i posted to it...no judgement on anyone's ability
> or the quality of the suggestions, just a frustratingly simple reality.  i
> had it typed correctly and it didn't work...

This could well be a bug in your JDBC driver or RDBMS. Can you post
the stack trace? Hopefully we can work out what's causing it for you.
My guess would be something like MySQL not supporting parameterised
queries or similar. Trust donald when he says he's tested this stuff -
Him and 30 or 40 other people (at least). Do bear in mind that the rest
of us use different database engines -- from what I can tell, most of
the development team use PostgreSQL. I'm not going to start a discussion
on the relative merits of the different engines, but it may be worth
your while porting to PostgreSQL, and that's not just because of this
problem.

> sorry for seeming so short...this is my 32nd work hour in two days...that's
> no excuse, but it doesn't help to make me any more pleasant :-)

No problem. We all work _far_ too many hours a week too, just forgive us
if we're short in return.


Paul

-- 
Paul Russell                                 Email:   paul@luminas.co.uk
Technical Director                             Tel:  +44 (0)20 8553 6622
Luminas Internet Applications                  Fax:  +44 (0)870 28 47489
This is not an official statement or order.    Web:    www.luminas.co.uk

RE: Probs with INSERT and esql

Posted by Jon Brisbin <br...@ipa.net>.
blah> this is XSP, not JSP

very true...but i'm trying to figure out what i can and can't do with
cocoon...i don't really know that by adhering to the documentation...

blah> i guarantee that it works.

i always assumed that it *does* work, when used correctly, but my original
point was that i tried it in my own app's context...exactly how the
documentation and the archives suggested to do it...but i was getting
nullpointerexceptions when i posted to it...no judgement on anyone's ability
or the quality of the suggestions, just a frustratingly simple reality.  i
had it typed correctly and it didn't work...

sorry for seeming so short...this is my 32nd work hour in two days...that's
no excuse, but it doesn't help to make me any more pleasant :-)

jb


RE: Probs with INSERT and esql

Posted by Donald Ball <ba...@webslingerZ.com>.
On Sat, 24 Feb 2001, Jon Brisbin wrote:

> > esql:query doesn't let you put _logic_ inside it.
>
> aahemm...  if you start the logic node OUTSIDE the query, then you can do
> whatever you want inside the query with xsp:expr...the sample code was also
> directly copied, without any modifications, from a JSP page for testing
> purposes...i wanted to make the xsp:expr stuff work inside the query, and
> this is how i worked on accomplishing that...

this is XSP, not JSP

> > i hope i've made that clear, if nothing else.
>
> not sure if you were intentionally aiming for an arrogant, condescending,
> and demeaning tone here, but reference above anyway...

no, sorry. i did think the docs were clear, but i guess not. the contents
of esql:query must resolve to a string expression.

> > anyway, i'd do this: [blahblahblah]
>
> i tried that the first several times around, but was getting mysterious
> nullpointerexceptions...hence the experimentation with totally off-the-wall
> ways of doing things...

i guarantee that it works. why don't you try it before shooting me down?

- donald


RE: Probs with INSERT and esql

Posted by Jon Brisbin <br...@ipa.net>.
> good lord.

yes, he is good.

> esql:query doesn't let you put _logic_ inside it.

aahemm...  if you start the logic node OUTSIDE the query, then you can do
whatever you want inside the query with xsp:expr...the sample code was also
directly copied, without any modifications, from a JSP page for testing
purposes...i wanted to make the xsp:expr stuff work inside the query, and
this is how i worked on accomplishing that...

> i hope i've made that clear, if nothing else.

not sure if you were intentionally aiming for an arrogant, condescending,
and demeaning tone here, but reference above anyway...

> anyway, i'd do this: [blahblahblah]

i tried that the first several times around, but was getting mysterious
nullpointerexceptions...hence the experimentation with totally off-the-wall
ways of doing things...

jb


RE: Probs with INSERT and esql

Posted by Donald Ball <ba...@webslingerZ.com>.
On Sat, 24 Feb 2001, Jon Brisbin wrote:

> <esql:execute-query>
>     <esql:query>
>         <xsp:logic>
>             StringBuffer sql = new StringBuffer("insert into new_address
> values(");
>             sql.append(" '").append(request.getParameter("member_id"));
> 		...
>             System.err.println(sql.toString());
>             <xsp:expr>sql.toString()</xsp:expr>
>         </xsp:logic>
>     </esql:query>

good lord. esql:query doesn't let you put _logic_ inside it. read the
schema and/or the examples - i hope i've made that clear, if nothing else.
anyway, i'd do this:

<xsp:logic>
  if (request.getParameter("member_id")) {
    <esql:query>
      insert into whatever_table values (
      <esql:parameter><xsp:expr>request.getParameter("member_id")</xsp:expr></esql:parameter>
      )
    </esql:query>
  }
</xsp:logic>

- donald


RE: Probs with INSERT and esql

Posted by Jon Brisbin <br...@ipa.net>.

>* Jon Brisbin (brisbin@ipa.net) wrote :
>> java.lang.Exception: XSP Java Compiler: Compilation failed for
>> _member_profile_insert.java
>> 176: ')' expected.
>>                     StringBuffer sql = new StringBuffer("insert into
>> new_address values(");
>>                                 ^
>> 1 error

>Looks like it could be a bug. Can you provide us with the fragment of
>XML that caused it?

<esql:execute-query>
    <esql:query>
        <xsp:logic>
            StringBuffer sql = new StringBuffer("insert into new_address
values(");
            sql.append(" '").append(request.getParameter("member_id"));
		...
            System.err.println(sql.toString());
            <xsp:expr>sql.toString()</xsp:expr>
        </xsp:logic>
    </esql:query>
    ...

Thanks!

Jon Brisbin
www.jbrisbin.net


Re: Probs with INSERT and esql

Posted by Paul Russell <pa...@luminas.co.uk>.
* Jon Brisbin (brisbin@ipa.net) wrote :
> java.lang.Exception: XSP Java Compiler: Compilation failed for
> _member_profile_insert.java
> 176: ')' expected.
>                     StringBuffer sql = new StringBuffer("insert into
> new_address values(");
>                                 ^
> 1 error

Looks like it could be a bug. Can you provide us with the fragment of
XML that caused it?


Paul.

-- 
Paul Russell                                 Email:   paul@luminas.co.uk
Technical Director                             Tel:  +44 (0)20 8553 6622
Luminas Internet Applications                  Fax:  +44 (0)870 28 47489
This is not an official statement or order.    Web:    www.luminas.co.uk