PreparedStatements are a better solution, they will work regardless of the
DB being used, and may turn out to be faster.

> -----Original Message-----
> From: Nicholson, Dale [SMTP:[EMAIL PROTECTED]]
> Sent: 22 October 2002 05:50
> To:   [EMAIL PROTECTED]
> Subject:      Re: Storing HTML in database
>
> I'm not sure if it will work in mysql but for Oracle, to avoid the '
> problem
> you put '' to get around it.  In other words do something like this
> (modify
> as you like for JSP, this is from a bean).  So when you are inserting to
> the
> db, pass your string to a method like this to add the ''.
>
> private String fixTick( String str ) throws Exception  {
>         try{
>         StringBuffer strOut=new StringBuffer();
>         for(int intChar=0; intChar < str.length(); intChar++){
>             if(str.substring(intChar,intChar+1).equals("'")){
>                 strOut.append("'");
>             }
>             strOut.append(str.substring(intChar,intChar+1));
>         }
>         return strOut.toString();
>         }
>         catch(Exception e){
>             // Pass back an empty string if there is a null pointer
> exception.
>                 return "";
>         }
>     }
>
> Dale Nicholson
>
>
>
> -----Original Message-----
> From: Robert Misior [mailto:misior@;SALEM.EDU]
> Sent: Tuesday, October 22, 2002 9:08 AM
> To: [EMAIL PROTECTED]
> Subject: Storing HTML in database
>
>
> Hello,
>
> I'm looking for a good approach of storing HTML in mysql database (field
> type is text).  Currently I'm converting any character other then a
> number or  alpha character to it's ASCII value before the table is
> updated.  So far this  is working fine  except extra overhead and
> storage space.  The main reason why I'm doing it this way is  because I
> had problems with the sql statement being truncated  at the first
> appearance of a  ' in the HTML.
>  Would searching for ' and replacing them with \' be a bather solution
> or would using PreparedStatement fix this problem with '?
>
> Thanks for any suggestions,
> Robert
>
> ==========================================================================
> =
> 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
>
> ==========================================================================
> =
> 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
--

It is the strict policy of Truworths that its e-mail facility and all
e-mail communications emanating therefrom, should be utilised for
business purposes only and should conform to high professional and
business standards.   Truworths has stipulated certain regulations in
terms whereof strict guidelines relating to the use and content of
e-mail communications are laid down. The use of the Truworths e-mail
facility is not permitted for the distribution of chain letters or
offensive mail of any nature whatsoever.   Truworths hereby distances
itself from and accepts no liability in respect of the unauthorised
use of its e-mail facility or the sending of e-mail communications
for other than strictly business purposes.   Truworths furthermore
disclaims liability for any  unauthorised instruction for  which
permission was not granted.    Truworths Limited accepts no liability
for any consequences arising from or as a result of reliance on this
message unless it is in respect of bona fide Truworths business for
which proper authorisation has been granted.

Any recipient of an unacceptable communication, a chain letter or
offensive material of any nature is requested to notify the Truworths
e-mail administrator ([EMAIL PROTECTED]) immediately in order that
appropriate action can be taken against the individual concerned.

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