Skip site navigation (1) Skip section navigation (2)

Re: jdbc driver problem?

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: sathish kumar shanmugavelu <sathishkumar(dot)shanmugavelu(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: jdbc driver problem?
Date: 2006-05-16 05:42:53
Message-ID: 4469665D.6050607@opencloud.com (view raw or flat)
Thread:
Lists: 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

In response to

Responses

pgsql-jdbc by date

Next:From: Andy JeffersonDate: 2006-05-16 07:08:04
Subject: Re: JPOX Types.CHAR error
Previous:From: sathish kumar shanmugaveluDate: 2006-05-16 03:51:26
Subject: jdbc driver problem?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group