Data containing quotes creates problems when inserted into database. All the quotes should be doubled before attempting insertion. Following method can be used for that purpose.

Java Code:
public static String convertString(String source) {
  StringBuffer sb = new StringBuffer();

  for(int i = 0; i < source.length(); i++){
    sb.append(source.charAt(i));
    if(source.charAt(i)=='\'') sb.append('\'')
    }
  return sb.toString();
}