Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id CAEA09FA21A for ; Sat, 3 Feb 2007 01:59:30 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 68313-10 for ; Sat, 3 Feb 2007 01:59:27 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from web32014.mail.mud.yahoo.com (web32014.mail.mud.yahoo.com [68.142.207.111]) by postgresql.org (Postfix) with SMTP id C04A09FA26D for ; Sat, 3 Feb 2007 01:59:27 -0400 (AST) Received: (qmail 31182 invoked by uid 60001); 3 Feb 2007 05:59:27 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=5jfSkTvpq/3NK5IoJLrBnMKWT2yypP1T7jb7iOYW7xGv3GMqOa8q1MRrLnesVC241v5Qx1B67M6eZyGhu4V4TRsUZFiq2CeK9zVPQEek7ND0NYK5zBR7goC1X3VFD+VERZnrZw52qVXGrO72B4BGbghuwUY4elyzw6UJqXZwY9U=; X-YMail-OSG: _tTQ5bIVM1n43VYwmdNYelv9kcfeW1ZWupTgt2UGtI2AiaLg9HtJPKChxUvvi4uiEQf1zL5yU5Fik9zIDPCqEw_qY3B1Ix6DyMMJ5ZX2QAZGuKANGvpab0lKbKK9Ck2R4i8_Itziq5SDK_0- Received: from [71.242.7.214] by web32014.mail.mud.yahoo.com via HTTP; Fri, 02 Feb 2007 21:59:26 PST Date: Fri, 2 Feb 2007 21:59:26 -0800 (PST) From: "j.random.programmer" Subject: Re: PreparedStatements, LIKE and the % operator To: Dave Cramer Cc: pgsql-jdbc@postgresql.org In-Reply-To: <37697F6B-C1F1-448D-AFCA-E7C463FBA283@fastcrypt.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <26855.31012.qm@web32014.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.17 tagged_above=0 required=5 tests=BAYES_40, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS X-Spam-Level: *** X-Archive-Number: 200702/24 X-Sequence-Number: 16580 Hi: > Craps out how ? > > bar = like %?% That was a typo. Sorry. I wasn't using '=' at all. > > bar like '%?%' > is closer to the correct syntax That's what I was doing. The driver gives this error: ----------------------------- 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:52) at org.postgresql.core.v3.SimpleParameterList.setStringParameter(SimpleParameterList.java:117) at org.postgresql.jdbc2.AbstractJdbc2Statement.bindString(AbstractJdbc2Statement.java:2118) at org.postgresql.jdbc2.AbstractJdbc2Statement.setString(AbstractJdbc2Statement.java:1241) at org.postgresql.jdbc2.AbstractJdbc2Statement.setString(AbstractJdbc2Statement.java:1227) ....etc........ -------------------------------- I hacked around a bit and finally said: .... bar like ? and foo like ? ps.setString(1, "%" + myvalue + "%") ps.setString(2, "%" + my_other_value + "%") That worked but it's a bit counter-intuitive. Best regards, --j ____________________________________________________________________________________ Don't get soaked. Take a quick peak at the forecast with the Yahoo! Search weather shortcut. http://tools.search.yahoo.com/shortcuts/#loc_weather