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

Getting parse Error at or near character "and"

From
friend 4ever
Date:
<a href="mailto:pgsql-hackers@postgresql.org">Hi,<br /><br /> I am getting the parse error while i try to execute a
simplesql query in postgres.<br /><br /> java.sql.SQLException: ERROR: parser: parse error at or near "and" at
character58<br /><br /> The Query has been changed and it is very much like the below one<br /><br /> select * from emp
whereempName like 'XXXXX' and empId=206<br /><br /> when I try to execute the same query in the postgresql console it
isworking fine but when i try to execute the same as a prepared statement from my java code it is giving the
java.sql.SQLExceptionlike the above.<br /><br /> Do Anyone have the answer for this problem????????<br /><br />
Expectinga Quick response.<br /><br /> Here is my code:<br /> String
getEmpId=SQLQueriesHandler.getQuery("eis.toGetEmpId");<br/> psmt=conn.prepareStatement(getEmpId);<br />
psmt.setString(1,empForm.getEmpName());<br/> psmt.setInt(2,empForm.getDeptId());<br /> System.out.println("The Query to
empIdwith Parameters is : "+psmt.toString());<br /> rs=psmt.executeQuery(getEmpId);<br /><br /> where the query will be
like<br/><br /> select empId from empTab where empName like 'XXXXXXX' and deptId=13<br /><br /> And in the above code
empFormis the Struts ActionForm object and getters are the form beans.<br /> If i try to execute that as a statement it
isexecuting well.<br /> and also if i try to execute that query as a pprepare statement in the code itself it is
executingwell.<br /> The only problem is when i try to get the query from the properties file eg:query.properties<br
/><br/> The variable names are changed keeping the code as it is.</a><br /><br />Plz reply back soon<br /><a
href="mailto:pgsql-hackers@postgresql.org"><br/> Thanks in Advance.<br /><br /> Regards,<br /> urmyfriend </a><p><hr
size="1"/>Ahhh...imagining that irresistible "new car" smell?<br /> Check out <a
href="http://us.rd.yahoo.com/evt=48245/*http://autos.yahoo.com/new_cars.html;_ylc=X3oDMTE1YW1jcXJ2BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDbmV3LWNhcnM-">new
carsat Yahoo! Autos.</a> 

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

From
Richard Huxton
Date:
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"

From
Richard Huxton
Date:
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"

From
"Albe Laurenz"
Date:
> 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