Обсуждение: jdbc driver problem?

Поиск
Список
Период
Сортировка

jdbc driver problem?

От
"sathish kumar shanmugavelu"
Дата:

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

Re: jdbc driver problem?

От
Oliver Jowett
Дата:
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

Re: jdbc driver problem?

От
Oliver Jowett
Дата:
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

Re: jdbc driver problem?

От
"sathish kumar shanmugavelu"
Дата:
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@opencloud.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