Re: how to Escape single quotes with PreparedStatment

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: JavaNoobie <vivek(dot)mv(at)enzentech(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: how to Escape single quotes with PreparedStatment
Date: 2011-08-22 10:39:07
Message-ID: CA+0W9LNEMxVVkGACi2MQ+dxFZ_Q-XQ81GWenfmcnzqSkEjmFnQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On 22 August 2011 22:26, JavaNoobie <vivek(dot)mv(at)enzentech(dot)com> wrote:

>  String query="SELECT count(*) over () as ROWCOUNT,
> CONSUMER_ID,WENEXA_ID,CONSUMER_NAME,CONTACT_NO,residing_village from
> db_consumer WHERE lower(CONSUMER_NAME) LIKE (lower(?))OR (lower(?)='')  AND
> (lower(RESIDING_VILLAGE) LIKE (lower(?) OR (lower(?)='')) AND
> (lower(WENEXA_ID) LIKE (lower(?))OR(lower(?)='')) LIMIT ? OFFSET ?";

> It throws the previous error:org.postgresql.util.PSQLException: ERROR:
> syntax error at or near "LIMIT"
>  Position: 302
>        at
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
>        at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
> Any idea why this could be happening?

You have a syntax error in your query, just like the errors says.
Count the parentheses.

(I really can't believe this thread is still going)

Oliver

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Radosław Smogura 2011-08-22 12:11:53 Re: how to Escape single quotes with PreparedStatment
Previous Message Chris Wareham 2011-08-22 10:35:19 Re: how to Escape single quotes with PreparedStatment