I use the following:

   //
   // replace
   //
   // Replaces every occurrence of oldStr in s with newStr.
   //
   // Parameters:
   //    s:      The String to perform the replacement on
   //    oldStr: The substring to be replaced
   //    newStr: The substring to replace with
   //
   public String replace(String s, String oldStr, String newStr)
   {
      int pos = s.indexOf(oldStr);

      while (pos != -1) {
         s = s.substring(0, pos) + newStr +
                                    s.substring(pos + oldStr.length());
         pos = s.indexOf(oldStr, pos + newStr.length());
      }
      return s;

   }

-----Original Message-----
From: Anil John [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 02, 2001 8:54 AM
To: [EMAIL PROTECTED]
Subject: Re: Escaping ' in a SQL INSERT


I understand that...Just don't want to do that manually :)

Would rather use a replace function to to which I can feed in a string and
tell it to do the replace as you suggest. What I am looking for is the
existance of such a function and some code samples that people have used.

Anil


On Fri, 2 Feb 2001, Chitra Muthukrishnan wrote:

> Use double single quote .
> For example,
> if you want to insert  ab'c, your insert statement will be like this :
>
> insert into tablename(field1)  values(value1,'ab''c);
>
> M.Chitra
> www.3rdagenda.com
>
>
>
> ----- Original Message -----
> From: Anil John <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, February 02, 2001 6:56 AM
> Subject: Escaping ' in a SQL INSERT
>
>
> > Greetings,
> >
> > I am new to JSP, so if this question has been asked and aswered before,
> > please point me to the FAQ.
> >
> > If not, could someone provide a code sample of how you escape a ' when
> > doing a SQL Insert in JSP?
> >
> > I am familiar with the VBScript replace function that would allow you to
> > do this and am hoping that there is a corresponding JSP function.
> >
> > Anil
> >
> > --
> > _______________________________________________________________
> > Anil John
> > [EMAIL PROTECTED] [PGP Key Available]
> >
> >
> ===========================================================================
> > 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
>
>

--
_______________________________________________________________
Anil John
[EMAIL PROTECTED] [PGP Key Available]

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

Reply via email to