pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: sathish kumar shanmugavelu <sathishkumar.shanmugavelu@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: jdbc driver problem?
Date: Tue, 16 May 2006 14:42:53 +0900
Message-ID: <4469665D.6050607@opencloud.com> (raw)
In-Reply-To: <ee0ad3a30605152051x21af0692jc6a5046096263471@mail.gmail.com>
References: <ee0ad3a30605152051x21af0692jc6a5046096263471@mail.gmail.com>

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



view thread (16+ messages)  latest in thread

Message-ID: <4469665D.6050607@opencloud.com>
Permalink:  ../4469665D.6050607@opencloud.com/
Also on:    postgresql.org/message-id/4469665D.6050607@opencloud.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: oliver@opencloud.com, sathishkumar.shanmugavelu@gmail.com
  Subject: Re: jdbc driver problem?
  In-Reply-To: <4469665D.6050607@opencloud.com>
  References: <ee0ad3a30605152051x21af0692jc6a5046096263471@mail.gmail.com> <4469665D.6050607@opencloud.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox