hi, for insert data in database the single quote will be 2 single quote
 use this for example:
String aString="I'll be happy";
aString=replace(aString,"'","''");// the second parameter are a single quote
and the third are 2 single quote

    //
    private String replace(String testo, String StrdaSost, String StrNuovo)
{
        int index=0;
        String Buffer = testo;

        if (Buffer.equalsIgnoreCase("")) return Buffer;

        while((index = Buffer.indexOf(StrdaSost, index)) >= 0) {
            Buffer = Buffer.substring(0,index)+ StrNuovo +
            Buffer.substring(index + StrdaSost.length());

            index += StrNuovo.length();
        }
        return Buffer;
    }

I hope this will help you
regards
Rinaldo Bonazzo
[EMAIL PROTECTED]

----- Original Message -----
From: "Tom & Sharon Kochanowicz" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 20, 2001 9:00 PM
Subject: Re: replacing apostrophes


> Strings are immutable, you need to create a new String, for example:
>
> String str = "aaabbbccc";
> String str2 = new String(str.replace('a','b'));
>
> T. Kochanowicz
>
>
> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's Java Servlet
> API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
> Barbara Johnson
> Sent: Thursday, September 20, 2001 1:54 PM
> To: [EMAIL PROTECTED]
> Subject: replacing apostrophes
>
>
> Hello All,
>
> I need to replace apostrophes from in the text a user puts in a form input
> textboxe before the text goes into the mysql database. If apostrophes go
> into the database it gets corrupted.
>
>
> I tried the "replace" function and can use it to replace a letter but am
> having trouble with the syntax to use
> to tell it to replace an  apostrophe because the function says to use
single
> quotes around the variables that you are replacing.
>
> This works:
> String str = "aaabbbccc";
> out.println (str.replace('a','b'));
>
> This doesn't work:
> String str = "aaabbbccc";
> out.println (str.replace(''',''''));
>
>
> I tried subsituting the outer single quotes with double quotes. That
doesn't
> work either.
> Any suggestions would be appreciated.
> Thanks,
> Barbara Johnson
> Instructional Applications Programmer
> [EMAIL PROTECTED]
> Northeastern Ohio Universities College of Medicine
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to