Login | Register
My pages Projects Community openCollabNet

Discussions > dev > Escaped/QuotedString classes

Project highlights: Architectural Overview

Discussion topic

Back to topic list

Escaped/QuotedString classes

Author dlr
Full name Daniel Rall
Date 2000-10-07 11:56:01 PDT
Message Dave, I was wondering if using both EscapedString and QuotedString
together handles internal single quotes? I noticed that the MySQL
driver (at least, version 2.0.2), handles the quotes in its
PreparedStatement.se​tString(String) method. There is a little conflict
using Escaped/QuotedString classes with MySQL drivers's
PreparedStatement because they both add external quotes. The MySQL
driver handles them via backslash escapes:

    public void setString(int parameterIndex, String X) throws
    // if the passed string is null, then set this column to null

    if(X == null) {
        set(parameterIndex, "null");
    else {
        StringBuffer B = new StringBuffer();
        int i;

        for (i = 0 ; i < X.length() ; ++i) {
        char c = X.charAt(i);
        if (c == '\\' || c == '\'' || c == '"') {
        set(parameterIndex, B.toString());

Daniel Rall <dlr at finemaltcoding dot com>

« Previous message in topic | 1 of 1 | Next message in topic »


Show all messages in topic

Escaped/QuotedString classes dlr Daniel Rall 2000-10-07 11:56:01 PDT
Messages per page: