Apostrophe problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bartlos
    New Member
    • Jan 2013
    • 3

    Apostrophe problem

    Hi, I'm developing a program which open text files from the system's hard drive using java language. The problem I'm encountering is when I save the content- whether it be in JPanel or JTextArea- which has some apostrophes to mysql database . I'll appreciate if I'm directed to articles which will enlighten me.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You need to escape the apostrophes in the value using a backslash before running the query.

    Comment

    • Bartlos
      New Member
      • Jan 2013
      • 3

      #3
      @Rabbit, I appreciate and value ur response. In my case though the scenario is a bit tricky. I open a ten pages file full of these apostrophes and I was wondering is there could b any way out by which I can be able to simply store the value in that jtextarea to mysql with its apostrophes without reporting this exceptions?

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        I didn't mean do it manually. Use a replace function to escape the quotes before running the query.

        Comment

        Working...