Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5uSE-0001GB-77 for pgsql-jdbc@arkaria.postgresql.org; Thu, 14 Feb 2013 08:46:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U5uSD-0006fd-L0 for pgsql-jdbc@arkaria.postgresql.org; Thu, 14 Feb 2013 08:46:05 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5uSC-0006fX-Nm for pgsql-jdbc@postgresql.org; Thu, 14 Feb 2013 08:46:04 +0000 Received: from h1.cmg2.smtp.forpsi.com ([81.2.195.188]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5uS8-0006fr-L2 for pgsql-jdbc@postgresql.org; Thu, 14 Feb 2013 08:46:04 +0000 Received: from [127.0.0.1] ([92.62.228.233]) by cmg2.smtp.forpsi.com with bizsmtp id 08lu1l00852mtl0018luWy; Thu, 14 Feb 2013 09:45:54 +0100 Message-ID: <511CA443.5020900@enaktyment.cz> Date: Thu, 14 Feb 2013 09:45:55 +0100 From: Ladislav DANKO User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: rounded brackets in prepared statement References: <511A926E.4080106@enaktyment.cz> <511AFB32.9080302@ttc-cmc.net> In-Reply-To: <511AFB32.9080302@ttc-cmc.net> 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 so JDBC driver is detecting matching type and if there's "=" (equal) then it's doing escaping and if there is "~" (regular expression pattern) the i need to do escaping by hand? laco On 13.2.2013 3:32, dmp wrote: > 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