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

Reply via email to