Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5SA1-0003Cb-0y for pgsql-jdbc@arkaria.postgresql.org; Wed, 13 Feb 2013 02:33:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U5SA0-0002lq-H4 for pgsql-jdbc@arkaria.postgresql.org; Wed, 13 Feb 2013 02:33:24 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5S9z-0002lk-KC for pgsql-jdbc@postgresql.org; Wed, 13 Feb 2013 02:33:23 +0000 Received: from outbound.vnet-inc.com ([216.146.104.103]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5S9x-0004nl-Dq for pgsql-jdbc@postgresql.org; Wed, 13 Feb 2013 02:33:22 +0000 Received: from [192.168.157.132] (unknown [76.75.27.41]) by outbound.vnet-inc.com (Postfix) with ESMTP id 222505A6C; Tue, 12 Feb 2013 19:33:21 -0700 (MST) Message-ID: <511AFB32.9080302@ttc-cmc.net> Date: Tue, 12 Feb 2013 19:32:18 -0700 From: dmp User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.13) Gecko/20100914 SeaMonkey/2.0.8 MIME-Version: 1.0 To: Ladislav DANKO , pgsql-jdbc@postgresql.org Subject: Re: rounded brackets in prepared statement References: <511A926E.4080106@enaktyment.cz> In-Reply-To: <511A926E.4080106@enaktyment.cz> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org It appears that since the argument to your prepare statement is a WHERE operation and you are using the ~, Match Regular Expression Case Sensitive, operator then the input is deemed as such. So parenthesis are valid constructs in these cases. Example from Documentation: POSIX Regular Expression Patterns Chapter 9. Functions & Operators 'abc' ~ '(b|d)' true 'abc' ~ '(^(b|c)' false danap. Ladislav DANKO wrote: > Hi folks, > > my setup: Java 1.6, JDBC PostgreSQL JDBC4 driver 9.1-903. > > Why when I do: > > PreparedStatement ps = myConnection.prepareStatement("SELECT a,b,c FROM > mytable WHERE category ~ ?"); > ps.setString(1, "my/super/category/a(bcdef"); > result = ps.executeQuery(); > > I need to escape rounded bracket in setString in this way: > ps.setString(1, "super/category/a(bcdef".replaceAll("\\(", "\\\\("))); > > I think it has somethink to do with regular expessions but ot know much > more about it. > > -- > With kind regards, > > Ladislav DANKO -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc