hi.
seems rather trivial: try putting the name in single quotes like
select * from description where name = '<%= request.getParameter
("name")'
suppose your searchstring sholdn't be truncated anymore...
greetings
sufi malak
<[EMAIL PROTECTED] An: [EMAIL PROTECTED]
OM> Kopie:
Gesendet von: A Thema: Syntax error or access violation
(sql)
mailing list
about Java Server
Pages
specification and
reference
<JSP-INTEREST@jav
a.sun.com>
18.04.2001 20:01
Bitte antworten
an A mailing list
about Java Server
Pages
specification and
reference
Hi, here is what I am trying to do :
veiwprogram.jsp :
<%@ taglib uri="http://jakarta.apache.org/taglibs/jdbc" prefix="sql" %>
<% String name = request.getParameter("name"); %>
<% out.println(" The name is >>>>>:" + name); %>
<sql:connection id="conn1">
<sql:url>jdbc:mysql://localhost/test</sql:url>
<sql:driver>org.gjt.mm.mysql.Driver</sql:driver>
</sql:connection>
<sql:preparedStatement id="stmt2" conn="conn1">
<sql:query>
select * from description where name = <%= request.getParameter("name")
%>
</sql:query>
<sql:resultSet id="rset1">
<pg:item>
<sql:getColumn position="1"/><br>
<sql:getColumn position="2"/><br>
<sql:getColumn position="3"/><br>
<sql:getColumn position="4"/><br>
<sql:getColumn position="5"/><br>
<sql:getColumn position="6"/><br>
<sql:getColumn position="7"/><br>
</pg:item>
</sql:resultSet>
<sql:wasEmpty>No rows retrieved.</sql:wasEmpty>
<sql:wasNotEmpty><sql:rowCount/> rows retrieved.</sql:wasNotEmpty>
</sql:preparedStatement>
I am calling this file from another jsp file called pager-jdbc.jsp:
..................
<td width="240" VALIGN="top"><a href="viewprogram.jsp?name= <%=
rset1.getString(1) %>">
<sql:getColumn position="1"/></a></td>
..................
This file is sending correctly whatever name I click in it to
viewprogram.jsp .
NOW FOR EXAMPLE :
When I click in the link that has the text : Big Picture Training
I got error saying :
javax.servlet.ServletException: java.sql.SQLException: Syntax error or
access violation: You have an error in your SQL syntax near 'Picture
Training' at line 1
When I click to another one, for example : Business Writting
I got this error :
javax.servlet.ServletException: java.sql.SQLException: Syntax error or
access violation: You have an error in your SQL syntax near 'Writting' at
line 1
IT LOOKS LIKE THE FIRST WORD IN THE STRING IS TRUNCATED, I don't understand
why ??
>From: Clayton Nash <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
> reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: Unknown column ??
>Date: Wed, 18 Apr 2001 18:09:37 +0100
>
>What's the query you're trying to run -- please print it our from your
java
>app and pass that exactly. Your code below doesn't include any ' marks to
>delimit the search and is different to code samples further down. It's
>almost certain you're trying to execute a query like
> select * from table where name=big
>when it should be
> select * from table where name='big'
>
>Clayton
>
>
>-----Original Message-----
>From: A mailing list about Java Server Pages specification and reference
>[mailto:[EMAIL PROTECTED]]On Behalf Of sufi malak
>Sent: 18 April 2001 17:46
>To: [EMAIL PROTECTED]
>Subject: Re: Unknown column ??
>
>
>The same query from the command line is working fine.
>
> >From: Nishit Trivedi <[EMAIL PROTECTED]>
> >Reply-To: A mailing list about Java Server Pages specification and
> > reference <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: Re: Unknown column ??
> >Date: Wed, 18 Apr 2001 12:36:01 -0400
> >
> >error is EXACTLY as stated...
> >"Unknown column 'Big' in where clause..
> >
> >Please try to print query before executing it...
> >or try to execute same query through command line..
> >
> >Nishit
> >
> >-----Original Message-----
> >From: sufi malak [mailto:[EMAIL PROTECTED]]
> >Sent: Wednesday, April 18, 2001 12:15 PM
> >To: [EMAIL PROTECTED]
> >Subject: Unknown column ??
> >
> >
> >I am still struggling with the same problem, could you please tell me
why
> >is
> >this error :
> >javax.servlet.ServletException: java.sql.SQLException: Column not found:
> >Unknown column 'Big' in 'where clause'
> >
> >The code is like this :
> ><sql:query>
> > select * from description where name = <%=
> >request.getParameter("name")
> >%>
> > </sql:query>
> >
> >Thanks
> >
> >
> > >From: sufi malak <[EMAIL PROTECTED]>
> > >Reply-To: A mailing list about Java Server Pages specification and
> > > reference <[EMAIL PROTECTED]>
> > >To: [EMAIL PROTECTED]
> > >Subject: Re: jdbc taglib question ?? No rows selected
> > >Date: Wed, 18 Apr 2001 14:52:58 -0000
> > >
> > >Hi, I just read the documentation again, from apache site :
> > >http://jakarta.apache.org/taglibs/doc/jdbc-doc/index.html#escapeSql
> > >And I changed the sql quer to :
> > >
> > ><sql:query>
> > > select * from description where name =
> > >'<sql:escapeSql><%=request.getParameter("name")%></sql:escapeSql>'
> > > </sql:query>
> > >BUT STILL DOES NOT WORK, ALWAYS I get no rows selected.
> > >
> > >
> > >
> > >
> > >>From: sufi malak <[EMAIL PROTECTED]>
> > >>Reply-To: A mailing list about Java Server Pages specification and
> > >> reference <[EMAIL PROTECTED]>
> > >>To: [EMAIL PROTECTED]
> > >>Subject: Re: jdbc taglib question ???
> > >>Date: Wed, 18 Apr 2001 12:59:47 -0000
> > >>
> > >>Hi,
> > >>1)
> > >><sql:query>
> > >> select * from description where name like <%= "'" +
> > >>request.getParameter("name") + "'"%>
> > >> </sql:query>
> > >>2)
> > >><sql:query>
> > >> select * from description where name like '<%=
> > >>request.getParameter("name") %>'
> > >> </sql:query>
> > >>
> > >>Both (1) and (2) don't work.
> > >>
> > >>
> > >>>From: Richard Yee <[EMAIL PROTECTED]>
> > >>>Reply-To: A mailing list about Java Server Pages specification and
> > >>> reference <[EMAIL PROTECTED]>
> > >>>To: [EMAIL PROTECTED]
> > >>>Subject: Re: jdbc taglib question ?????
> > >>>Date: Tue, 17 Apr 2001 13:26:57 -0700
> > >>>
> > >>>Sufi,
> > >>>You need single quotes around the string in your like clause.
> > >>>select * from description where name like '<%=
> > >>>request.getParameter("name")
> > >>>%>'
> > >>>
> > >>>If that doesn't work you might have to do
> > >>>select * from description where name like <%= "'" +
> > >>>request.getParameter("name") + "'" %>
> > >>>
> > >>>
> > >>>-Richard
> > >>>
> > >>>-----Original Message-----
> > >>>From: sufi malak [mailto:[EMAIL PROTECTED]]
> > >>>Sent: Tuesday, April 17, 2001 1:16 PM
> > >>>To: [EMAIL PROTECTED]
> > >>>Subject: jdbc taglib question ?????
> > >>>
> > >>>
> > >>>could you please tell me what's wrong in this line:
> > >>>select * from description where name like <%=
> > >>>request.getParameter("name")
> > >>>%>
> > >>>
> > >>>
> > >>>the file is like this :
> > >>>..........
> > >>><%@ taglib uri="http://jakarta.apache.org/taglibs/jdbc" prefix="sql"
>%>
> > >>>
> > >>><% String name = request.getParameter("name"); %>
> > >>><% out.println(" The name is >>>>>:" + name); %>
> > >>>
> > >>><sql:connection id="conn1">
> > >>> <sql:url>jdbc:mysql://localhost/test</sql:url>
> > >>> <sql:driver>org.gjt.mm.mysql.Driver</sql:driver>
> > >>></sql:connection>
> > >>>
> > >>><sql:preparedStatement id="stmt2" conn="conn1">
> > >>> <sql:query>
> > >>> select * from description where name like <%=
> > >>>request.getParameter("name") %>
> > >>> </sql:query>
> > >>> <sql:resultSet id="rset1">
> > >>> <pg:item>
> > >>> <sql:getColumn position="1"/><br>
> > >>> <sql:getColumn position="2"/><br>
> > >>>..............
> > >>>_________________________________________________________________
> > >>>Get your FREE download of MSN Explorer at http://explorer.msn.com
> > >>>
> >
> >>>
=========================================================================
> >==
> > >>>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > >>>JSP-INTEREST".
> > >>>For digest: mailto [EMAIL PROTECTED] with body: "set
JSP-INTEREST
> > >>>DIGEST".
> > >>>Some relevant FAQs on JSP/Servlets can be found at:
> > >>>
> > >>> http://java.sun.com/products/jsp/faq.html
> > >>> http://www.esperanto.org.nz/jsp/jspfaq.html
> > >>> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > >>> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> > >>>
> >
> >>>
=========================================================================
> >==
> > >>>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > >>>JSP-INTEREST".
> > >>>For digest: mailto [EMAIL PROTECTED] with body: "set
JSP-INTEREST
> > >>>DIGEST".
> > >>>Some relevant FAQs on JSP/Servlets can be found at:
> > >>>
> > >>> http://java.sun.com/products/jsp/faq.html
> > >>> http://www.esperanto.org.nz/jsp/jspfaq.html
> > >>> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > >>> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> > >>
> > >>_________________________________________________________________
> > >>Get your FREE download of MSN Explorer at http://explorer.msn.com
> > >>
> >
> >>
==========================================================================
> >=
> > >>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > >>JSP-INTEREST".
> > >>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> > >>DIGEST".
> > >>Some relevant FAQs on JSP/Servlets can be found at:
> > >>
> > >>http://java.sun.com/products/jsp/faq.html
> > >>http://www.esperanto.org.nz/jsp/jspfaq.html
> > >>http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > >>http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> > >
> > >_________________________________________________________________
> > >Get your FREE download of MSN Explorer at http://explorer.msn.com
> > >
> >
> >
===========================================================================
> > >To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > >JSP-INTEREST".
> > >For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> > >DIGEST".
> > >Some relevant FAQs on JSP/Servlets can be found at:
> > >
> > >http://java.sun.com/products/jsp/faq.html
> > >http://www.esperanto.org.nz/jsp/jspfaq.html
> > >http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > >http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
> >_________________________________________________________________
> >Get your FREE download of MSN Explorer at http://explorer.msn.com
> >
> >
===========================================================================
> >To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> >JSP-INTEREST".
> >For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> >DIGEST".
> >Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
> >
===========================================================================
> >To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> >JSP-INTEREST".
> >For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> >DIGEST".
> >Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>_________________________________________________________________
>Get your FREE download of MSN Explorer at http://explorer.msn.com
>
>
===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
>DIGEST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>
===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
>DIGEST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets