sathish kumar shanmugavelu wrote:
> We used a query like
> SELECT * FROM patient_head WHERE patient_name = ?
> in the prepared statement. And set the parameter as setString(1,name)
> , where 'name' is the java string variable.
> while printing the prepared statement the query is displayed like
> SELECT * FROM patient_head WHERE patient_name = James Cameroon
> instead of
> SELECT * FROM patient_head WHERE patient_name = 'James
> with single quotes.
The JDBC API doesn't require that PreparedStatement.toString() will
return the actual SQL to be executed, and the current driver doesn't try
to get string escaping correct in toString(). It's a purely cosmetic
issue, the query is correct when sent to the server. In fact, at the
protocol level, the parameter values are *not* interpolated into the
query string, they are sent separately.
> It happens in both the 7.4.7 and 8.1 version of the postgresql.
> Because of this the query does not executes and no result is fetched.
The cause of your problem is something else. The return value of
toString() is not relevant.
If you run the same query via psql, does it return results?
In response to
pgsql-jdbc by date
|Next:||From: Andy Jefferson||Date: 2006-05-16 07:08:04|
|Subject: Re: JPOX Types.CHAR error|
|Previous:||From: sathish kumar shanmugavelu||Date: 2006-05-16 03:51:26|
|Subject: jdbc driver problem?|