Re: I'm reading the source now...

From: Barry Lind <barry(at)xythos(dot)com>
To: tony <tony(at)animaproductions(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: I'm reading the source now...
Date: 2002-05-01 00:30:47
Message-ID: 3CCF3737.3000707@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Tony,

setEscapeProcessing() and escapeSQL() do not do what you think they do.
They have nothing to do with quotes and such. Their purpose is as
defined in the jdbc spec to deal with handling special Escape commands
like the following: {d '2001-10-09'} . This allows one to put a date
literal into a sql statement without knowing the specific date format a
particular RDBMS might be expecting. These special escapes are designed
to help jdbc code be more database independent. The postgres jdbc
driver does not support all of the special Escapes defined by the jdbc
spec, but according to the source code it does support:

/*
* Filter the SQL string of Java SQL Escape clauses.
*
* Currently implemented Escape clauses are those mentioned in 11.3
* in the specification. Basically we look through the sql string for
* {d xxx}, {t xxx} or {ts xxx} in non-string sql code. When we find
* them, we just strip the escape part leaving only the xxx part.
* So, something like "select * from x where d={d '2001-10-09'}" would
* return "select * from x where d= '2001-10-09'".
*/

thanks,
--Barry

tony wrote:
> Hello,
>
> Trying to figure out how to integrate
> Statement.setEscapeProcessing(true)
>
> into a JSP it came upon me that to make the JSP RDBMS independant this
> code should be in the driver. So I downloaded the source and came up
> with
>
> public boolean execute(String sql) throws SQLException
> {
> if (escapeProcessing)
> sql = escapeSQL(sql);
>
> in statement. I'm using preparedStatement which if one reads Suns doc
> correctly escape characters "automagically".
>
> Can I just use escapeSQL in my query???
>
> Cheers
>
> Tony Grant
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tim Pizey 2002-05-01 00:59:51 Newbie, just starting
Previous Message Thomas O'Dowd 2002-04-30 23:25:07 Re: I'm reading the source now...