Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 3B573B5DBE0 for ; Mon, 22 Aug 2011 01:44:35 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 16335-01 for ; Mon, 22 Aug 2011 04:44:28 +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 574E4B5DBBE for ; Mon, 22 Aug 2011 01:44:28 -0300 (ADT) Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1QvMN9-0007o1-1w for pgsql-jdbc@postgresql.org; Sun, 21 Aug 2011 21:44:27 -0700 Date: Sun, 21 Aug 2011 21:44:27 -0700 (PDT) From: JavaNoobie To: pgsql-jdbc@postgresql.org Message-ID: <1313988267050-4722152.post@n5.nabble.com> In-Reply-To: <201108211245.14465.mail@smogura.eu> References: <1313841345919-4718287.post@n5.nabble.com> <201108211245.14465.mail@smogura.eu> 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/47 X-Sequence-Number: 22079 Hi All , Thank you all for your replies. The prepared statement block that I try to execute , after adding parameters is as follows ,(I've simplified the query so that I can understand the concept) 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(%\"?\"%))"; stmt = con.prepareStatement(query); stmt.setString(1, name); rs= stmt.executeQuery(); However upon executing the block, I get an error as follows org.postgresql.util.PSQLException: The column index is out of range: 1, number of columns: 0. at org.postgresql.core.v3.SimpleParameterList.bind(SimpleParameterList.java:53) at org.postgresql.core.v3.SimpleParameterList.setStringParameter(SimpleParameterList.java:118) at org.postgresql.jdbc2.AbstractJdbc2Statement.bindString(AbstractJdbc2Statement.java:2184) at org.postgresql.jdbc2.AbstractJdbc2Statement.setString(AbstractJdbc2Statement.java:1303) at org.postgresql.jdbc2.AbstractJdbc2Statement.setString(AbstractJdbc2Statement.java:1289) at com.enzen.cis.dao.DAOConsumerSearch.getcList(DAOConsumerSearch.java:5 Any idea why this could be happening? Thank you. -- View this message in context: http://postgresql.1045698.n5.nabble.com/how-to-Escape-single-quotes-with-PreparedStatment-tp4718287p4722152.html Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.