title: How do I handle special characters in a Java PrepareStatement?
body: <p>In the following SQL query using the <code>PreparedStatement</code> class:</p>
  
  <pre><code>String query_descrip = "insert into timitemdescription (itemkey, languageid, longdesc, shortdesc) values (?, 1033, ?,?)";
  PreparedStatement pstmt2 = con.prepareStatement(query_descrip); 
  pstmt2.setInt(1, rs4);
  pstmt2.setString(2, itemdescription);
  pstmt2.setString(3, itemdescription.substring(0,39));
  pstmt2.executeUpdate();       
  </code></pre>
  
  <p>I sometimes get apostrophes and single and double quotes in my item descriptions.  for example, my late issue with one item is a "Planar 22" monitor".  Of course, the string was misinterpreted and thought the description value was just "Planar 22".
  What is the best way to handle special characters in a string? </p>
  
  <p>I've read that some people are using regex, however these seemed to be specific to a case by case basis.  Another way I'm working on is reading the string array character by character. I was hoping there was a more efficient and less resource-intensive way of doing this. </p>
  
  <p>UPDDATE
  AFter some more extensive testing, it turns out there were more problems occuring in my code.  it was also a URL Encoding problem.  When the html form was being populated by the jsp code,it would try to move the description field to an online form, it truncates it there on the form rather than on the query. jTDS also corrected the problem receiving the special characters.  Because jTDS is a jar, it also helped avoid rebooting the machine.  I will award the jTDS thread the bounty since that was what I partially used. </p>
  
  <p>thanks in advance</p>