stringValue = "'" + stringValue + "'";
if (stringValue.indexOf("'") < 0) { return stringValue = "'" + stringValue + "'"; }   StringBuffer buffer = new StringBuffer(stringValue.length() * 2); StringTokenizer tokenizer = new StringTokenizer(stringValue, "'", true);  buffer.append("'"); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); buffer.append(token); if (token.equals("'")) { buffer.append("'"); } } buffer.append("'"); return buffer.toString();
    public static String getSqlValueString(Object value, DataType dataType)            throws TypeCastException    {        if (value == null)        {            return "NULL";        }        String stringValue = DataType.asString(value);        if (dataType == DataType.DATE)        {            return "{d '" + stringValue + "'}";        }        if (dataType == DataType.TIME)        {            return "{t '" + stringValue + "'}";        }        if (dataType == DataType.TIMESTAMP)        {            return "{ts '" + stringValue + "'}";        }        if (!dataType.isNumber())        {            stringValue = "'" + stringValue + "'";        }        return stringValue;    }