Re: jdbc driver problem?

Lists: pgsql-jdbc
From: "sathish kumar shanmugavelu" <sathishkumar(dot)shanmugavelu(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: jdbc driver problem?
Date: 2006-05-16 03:51:26
Message-ID: ee0ad3a30605152051x21af0692jc6a5046096263471@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hi all,
Iam using postgresql-8.2dev-501.jdbc3.jar jdbc.
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.
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.
Why? do i miss anything? please help?

with advanced thanks
--
Sathish Kumar.S
SpireTEK


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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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


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-17 10:06:30
Message-ID: 446AF5A6.9020904@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

sathish kumar shanmugavelu wrote:
> Hi Oliver Jowett,
> Yes if i run in psql it returns the result.
> Even if i use pg73jdbc3.jar - postgresql jdbc driver it works fine.
> please help
> thanks in advance

Hi,

Please post to the list, not only to me.

It may be an encoding/locale problem (though your example appears to be
plain 7-bit ascii so I'm not sure). What encoding and locale does your
database use?

Can you give us a complete testcase that shows the problem?

-O


From: "sathish kumar shanmugavelu" <sathishkumar(dot)shanmugavelu(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: jdbc driver problem?
Date: 2006-05-20 09:27:04
Message-ID: ee0ad3a30605200227j42a1e97bn2097385dd5f258d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

hi,
We use UTF-8 encoding for the database.
what infm. are needed in testcase

thanks in advance

On 5/17/06, Oliver Jowett <oliver(at)opencloud(dot)com> wrote:
>
> sathish kumar shanmugavelu wrote:
> > Hi Oliver Jowett,
> > Yes if i run in psql it returns the result.
> > Even if i use pg73jdbc3.jar - postgresql jdbc driver it works fine.
> > please help
> > thanks in advance
>
> Hi,
>
> Please post to the list, not only to me.
>
> It may be an encoding/locale problem (though your example appears to be
> plain 7-bit ascii so I'm not sure). What encoding and locale does your
> database use?
>
> Can you give us a complete testcase that shows the problem?
>
> -O
>

--
Sathish Kumar.S
SpireTEK