single quotes again

Поиск
Список
Период
Сортировка
От tony
Тема single quotes again
Дата
Msg-id 1018082784.4094.7.camel@annix
обсуждение исходный текст
Ответы Re: single quotes again  (tony <tony@animaproductions.com>)
Список pgsql-jdbc
Hello,

In looking around for a way to insert entries via html for via JDBC
containing single quotes I came upon this:

escapeQuotes

protected java.lang.String escapeQuotes(java.lang.String old)

Tokenizes the original string with \' and \" as delimiters, then
replaces them with \\\' and \\\", respectively. This is primarily useful
for escaping quotes that will be interpreted as part of a mySQL query.

Is there a method like this that is callable for Postgresql  JDBC driver
too?

I also found this method

private String escape(String s) {
    String retvalue = s;
    if ( s.indexOf ("'") != -1 ) {
    StringBuffer hold = new StringBuffer();
    char c;
    for ( int i = 0; i < s.length(); i++ ) {
        if ( (c=s.charAt(i)) == '\'' )
        hold.append ("''");
        else
        hold.append(c);
    }
    retvalue = hold.toString();
    }
    return retvalue;
}

Not being a java god - where do I insert this in my jsp code? Each form
has several fields where single quotes may be inserted.

TIA

Cheers

Tony Grant


--


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: Syntax of LIKE in PreparedStatement
Следующее
От: tony
Дата:
Сообщение: Re: single quotes again