Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 4FC45B5DBDA for ; Mon, 22 Aug 2011 06:56:57 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 34705-05 for ; Mon, 22 Aug 2011 09:56:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sam.nabble.com (sam.nabble.com [216.139.236.26]) by mail.postgresql.org (Postfix) with ESMTP id B6460B5D803 for ; Mon, 22 Aug 2011 06:56:50 -0300 (ADT) Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1QvRFR-0007y9-Nu for pgsql-jdbc@postgresql.org; Mon, 22 Aug 2011 02:56:49 -0700 Date: Mon, 22 Aug 2011 02:56:49 -0700 (PDT) From: JavaNoobie To: pgsql-jdbc@postgresql.org Message-ID: <1314007009734-4722805.post@n5.nabble.com> In-Reply-To: <4E5225B1.1030506@ahastie.net> References: <1313841345919-4718287.post@n5.nabble.com> <201108211245.14465.mail@smogura.eu> <1313988267050-4722152.post@n5.nabble.com> <201108220946.37783.ml-tb@emagixx.de> <1314000874022-4722528.post@n5.nabble.com> <4E5225B1.1030506@ahastie.net> Subject: Re: how to Escape single quotes with PreparedStatment MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.778 tagged_above=-10 required=5 tests=BAYES_00=-1.9, URI_HEX=1.122 X-Spam-Level: X-Archive-Number: 201108/51 X-Sequence-Number: 22083 Hi Andrew, Thanks for the reply. I'm, able to do that effectively . here's my corrected code snippet 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 ?"; stmt = con.prepareStatement(query); stmt.setString(1,"%"+name+"%"); stmt.setString(2,"%"+name+"%"); stmt.setString(3,"%"+village+"%"); stmt.setString(4,"%"+village+"%"); stmt.setString(5,"%"+wenexaid+"%"); stmt.setString(6,"%"+wenexaid+"%"); stmt.setInt(7,pageLimit); stmt.setInt(8,pageOffset); rs= stmt.executeQuery(); However , it throws near the LIMIT clause. As below: 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) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) Any idea about this one? -- View this message in context: http://postgresql.1045698.n5.nabble.com/how-to-Escape-single-quotes-with-PreparedStatment-tp4718287p4722805.html Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.