Getting parse Error at or near character "and"

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

Getting parse Error at or near character "and"

От:
friend 4ever <urmyfriend14@yahoo.com>
Дата:
Hi,

I am getting the parse error while i try to execute a simple sql query in postgres.

java.sql.SQLException: ERROR: parser: parse error at or near "and" at character 58

The Query has been changed and it is very much like the below one

select * from emp where empName like 'XXXXX' and empId=206

when I try to execute the same query in the postgresql console it is working fine but when i try to execute the same as a prepared statement from my java code it is giving the java.sql.SQLException like the above.

Do Anyone have the answer for this problem????????

Expecting a Quick response.

Here is my code:
String getEmpId=SQLQueriesHandler.getQuery("eis.toGetEmpId");
psmt=conn.prepareStatement(getEmpId);
psmt.setString(1,empForm.getEmpName());
psmt.setInt(2,empForm.getDeptId());
System.out.println("The Query to empId with Parameters is : "+psmt.toString());
rs=psmt.executeQuery(getEmpId);

where the query will be like

select empId from empTab where empName like 'XXXXXXX' and deptId=13

And in the above code empForm is the Struts ActionForm object and getters are the form beans.
If i try to execute that as a statement it is executing well.
and also if i try to execute that query as a pprepare statement in the code itself it is executing well.
The only problem is when i try to get the query from the properties file eg:query.properties

The variable names are changed keeping the code as it is.


Plz reply back soon

Thanks in Advance.

Regards,
urmyfriend


Ahhh...imagining that irresistible "new car" smell?
Check out new cars at Yahoo! Autos.

Re: Getting parse Error at or near character "and"

От:
Richard Huxton <dev@archonet.com>
Дата:
friend 4ever wrote:
> Hi,
>  
>  I am getting the parse error while i try to execute a simple sql query in postgres.

This isn't a question for the hackers list.

Try the general, or jdbc lists.

--   Richard Huxton  Archonet Ltd

Re: Getting parse Error at or near character "and"

От:
Richard Huxton <dev@archonet.com>
Дата:
friend 4ever wrote:
> Hi,
>  
>  I am getting the parse error while i try to execute a simple sql query in postgres.
>  
>  java.sql.SQLException: ERROR:  parser: parse error at or near "and" at character 58
>  
>   The Query has been changed  and it is very much like the below one

Oh, and the quickest way to find out what the error is would be to 
provide the *actual* query, not something very much like it. Perhaps 
turn statement logging on in your postgresql.conf if it isn't already.

--   Richard Huxton  Archonet Ltd

Re: Getting parse Error at or near character "and"

От:
"Albe Laurenz" <all@adv.magwien.gv.at>
Дата:
> Expecting a Quick response.

Don't hold your breath.
Please post questions like this to the JDBC and/or the 'general' mailing
list.

Yours,
Laurenz Albe

FAQ