String query=new StringBuffer("select name,subj_id,reply,subject,time from post "). 
append("where subject like '%").append(search).append("%' ").toString();

should do the trick ... ???

michi

--------------------------------------------------------------------------
2001 Nov 02 - 03:10
yilmaz <[EMAIL PROTECTED]>
--------------------------------------------------------------------------
>hi all,
>I wrote a messge board servlet which is working fine.
>but now i am working on  a website, and i thought i had better use jsp to
>develop the site, so i decided to convert my servlet into a jsp, slicing it
>into pieces. Two of them just works fine.
>for the third one, which takes care of the search task,can't be converted
>because of  a servlet exception saying that :
>javax.servlet.ServletException: [Microsoft][ODBC Microsoft Access Driver]
>Too few parameters, two expected.
>i know that , this is because the sql query which includes single quotes
>inside as below:
>String query="select name,subj_id,reply,subject,time  from post "+
>         "where subject like '%"+search+"%' ";
>it is obvious that the parser can't see the search variable becasue of the
>single quotes. But how can i avoid this? I tried using escape chars , didn't
>work.Is there any workarounds ? thanks in advance.
>cheers :)
>
>===========================================================================
>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://archives.java.sun.com/jsp-interest.html
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.jsp
> http://www.jguru.com/faq/index.jsp
> http://www.jspinsider.com
>


Reply via email to