title: How to insert a value with single apostrophe in DB2
body: <p>My requirement is to insert a value which contains an apostrophe,(e.g St.Mary's), into DB2 using a java query. </p>
  
  <p>My table has a column name with datatype Char(26) for this purpose and this cannot be changed.</p>
  
  <p>I've handled the apostrophe using the <a href="http://www.michael-thomas.com/tech/db2/db2_survival_guide.htm" rel="nofollow">DB2 Survival guide</a>, this way:</p>
  
  <pre><code>String CityName = beanClass.getCity();
          if(CityName.contains("'"))
          {
              CityName.replace("'","''");
          }   
    prepStmt.setString(1, CityName);
  </code></pre>
  
  <p>Query Looks like:</p>
  
  <pre><code>INSERT INTO TableName(CityName) VALUES(?);
  (Where values are being received from the preparedStatement(Index,String) (prepStmt.setString(int,string))
  </code></pre>
  
  <p>Please help me to insert the value "St.Mary's" with an apostrophe into DB2. </p>
  
  <p>Thanks loads, Varsha.</p>