Re: jdbc driver problem? - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: jdbc driver problem?
Date
Msg-id 4469665D.6050607@opencloud.com
Whole thread Raw
In response to jdbc driver problem?  ("sathish kumar shanmugavelu" <sathishkumar.shanmugavelu@gmail.com>)
List pgsql-jdbc
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
> Cameroon'
>    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?

-O

pgsql-jdbc by date:

Previous
From: "sathish kumar shanmugavelu"
Date:
Subject: jdbc driver problem?
Next
From: Andy Jefferson
Date:
Subject: Re: JPOX Types.CHAR error