From hugo_sacramento@yahoo.com.br Fri Feb 24 17:45:53 2006 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id B5CA79DCC58 for ; Fri, 24 Feb 2006 13:45:53 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59078-06 for ; Fri, 24 Feb 2006 13:45:52 -0400 (AST) X-Greylist: delayed 00:06:40.576126 by SQLgrey- Received: from web33010.mail.mud.yahoo.com (web33010.mail.mud.yahoo.com [68.142.206.74]) by postgresql.org (Postfix) with SMTP id DC4FE9DCBE1 for ; Fri, 24 Feb 2006 13:45:50 -0400 (AST) Received: (qmail 421 invoked by uid 60001); 24 Feb 2006 17:39:09 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.br; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=mCFjV3YfTsOttayfEBsxPLL4ANS/wbg01aVfs+SnfML6/AqgyFU4Uu3aXQVxpaQQeNwexYlLJp2mZfm9txMG1Lz8RTcUFgOSx4oGPlkAWIoadn1XJxIZ2qifGHp0ULlr4j1hwUPinWgzInFwxlatYRIQdxNZx4DAbgsGQYg4zXs= ; Message-ID: <20060224173909.419.qmail@web33010.mail.mud.yahoo.com> Received: from [200.178.173.226] by web33010.mail.mud.yahoo.com via HTTP; Fri, 24 Feb 2006 14:39:09 ART Date: Fri, 24 Feb 2006 14:39:09 -0300 (ART) From: Hugo Sacramento Subject: Retrieve Query To: pgsql-jdbc@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-614299454-1140802749=:97818" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] X-Spam-Score: 0.001 X-Spam-Level: X-Archive-Number: 200602/168 X-Sequence-Number: 14765 --0-614299454-1140802749=:97818 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit How do I to retrieve the string query prepared by a PreparedStatement?? i.e.: ------------- PreparedStatement stmt = con.prepareStatement("select * from abc where x=?"); stmt.setString(1, x); System.out.println("My Prepared Query:" + stmt.toString()); ------------ but it don't work. --------------------------------- Yahoo! Acesso Grátis Internet rápida e grátis. Instale o discador agora! --0-614299454-1140802749=:97818 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit How do I to retrieve the string query prepared by a PreparedStatement??

i.e.:

-------------
PreparedStatement stmt = con.prepareStatement("select * from abc where x=?");
stmt.setString(1, x);
System.out.println("My Prepared Query:" + stmt.toString());
------------

but it don't work.




Yahoo! Acesso Grátis
Internet rápida e grátis. Instale o discador agora! --0-614299454-1140802749=:97818-- From schabi@logix-tt.com Mon Feb 27 10:38:30 2006 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 7D91D9DC81A for ; Mon, 27 Feb 2006 06:38:30 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 94775-08 for ; Mon, 27 Feb 2006 06:38:30 -0400 (AST) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 819D29DC818 for ; Mon, 27 Feb 2006 06:38:26 -0400 (AST) Received: from mail.logix-tt.com (unknown [212.211.145.186]) by svr4.postgresql.org (Postfix) with ESMTP id 7886E5AF0BB for ; Mon, 27 Feb 2006 10:38:29 +0000 (GMT) Received: from kingfisher.intern.logix-tt.com (Mc83a.m.pppool.de [89.49.200.58]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id 87A053000444; Mon, 27 Feb 2006 11:38:33 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id A1EFE181520E9; Mon, 27 Feb 2006 11:38:26 +0100 (CET) Message-ID: <4402D6A2.4080200@logix-tt.com> Date: Mon, 27 Feb 2006 11:38:26 +0100 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Hugo Sacramento Cc: pgsql-jdbc@postgresql.org Subject: Re: Retrieve Query References: <20060224173909.419.qmail@web33010.mail.mud.yahoo.com> In-Reply-To: <20060224173909.419.qmail@web33010.mail.mud.yahoo.com> X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.123 required=5 tests=[AWL=0.123] X-Spam-Score: 0.123 X-Spam-Level: X-Archive-Number: 200602/171 X-Sequence-Number: 14768 Hi, Hugo, Hugo Sacramento wrote: > How do I to retrieve the string query prepared by a PreparedStatement?? > ------------- > PreparedStatement stmt = con.prepareStatement("select * from abc where > x=?"); > stmt.setString(1, x); > System.out.println("My Prepared Query:" + stmt.toString()); > ------------ > > but it don't work. There are at least two potential problems: - The statement is prepared server-side, and the parameters are sent separately (binding). Only the server has the "real" representation of the complete statement. So the prepared statement can only give an approximation, which is what pgjdbc does. - Most connection pooling and datasource mechanisms (e. G. in jboss) wrap your connection and all other classes (including the statement), but don't delegate the toString() method, so you'll only get something like "org.jboss.pool.wrappedStatement@4711". HTH, Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org From achill@matrix.gatewaynet.com Mon Feb 27 10:51:24 2006 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 8D2039DC9DD for ; Mon, 27 Feb 2006 06:51:24 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98327-08 for ; Mon, 27 Feb 2006 06:51:26 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from matrix.gatewaynet.com (host2.dynacom.ondsl.gr [62.103.35.210]) by postgresql.org (Postfix) with ESMTP id 22BEA9DC825 for ; Mon, 27 Feb 2006 06:51:21 -0400 (AST) Received: from matrix.gatewaynet.com (localhost.localdomain [127.0.0.1]) by matrix.gatewaynet.com (8.12.8/8.12.8) with ESMTP id k1RBtbOp013424; Mon, 27 Feb 2006 13:55:37 +0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.8/8.12.8/Submit) with ESMTP id k1RBtVUi013418; Mon, 27 Feb 2006 13:55:31 +0200 Date: Mon, 27 Feb 2006 13:55:31 +0200 (EET) From: Achilleus Mantzios To: Markus Schaber cc: Hugo Sacramento , Subject: Re: Retrieve Query In-Reply-To: <4402D6A2.4080200@logix-tt.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-7 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.112 required=5 tests=[AWL=0.112] X-Spam-Score: 0.112 X-Spam-Level: X-Archive-Number: 200602/172 X-Sequence-Number: 14769 O Markus Schaber Ýãñáøå óôéò Feb 27, 2006 : > Hi, Hugo, > > Hugo Sacramento wrote: > > How do I to retrieve the string query prepared by a PreparedStatement?? > > > ------------- > > PreparedStatement stmt = con.prepareStatement("select * from abc where > > x=?"); > > stmt.setString(1, x); > > System.out.println("My Prepared Query:" + stmt.toString()); > > ------------ > > > > but it don't work. > > There are at least two potential problems: > > - The statement is prepared server-side, and the parameters are sent > separately (binding). Only the server has the "real" representation of > the complete statement. So the prepared statement can only give an > approximation, which is what pgjdbc does. > > - Most connection pooling and datasource mechanisms (e. G. in jboss) > wrap your connection and all other classes (including the statement), > but don't delegate the toString() method, so you'll only get something > like "org.jboss.pool.wrappedStatement@4711". In jboss there is getUnderlyingStatement() method so you could PreparedStatement st=... ..... org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement jst = (org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement) st; org.postgresql.jdbc3.Jdbc3PreparedStatement pst = (org.postgresql.jdbc3.Jdbc3PreparedStatement) jst.getUnderlyingStatement(); System.out.println(pst.toString()); > > HTH, > Markus > -- -Achilleus From hugo_sacramento@yahoo.com.br Fri Mar 3 00:37:05 2006 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 8F8F79DCB7B for ; Thu, 2 Mar 2006 20:37:05 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16179-06 for ; Thu, 2 Mar 2006 20:37:08 -0400 (AST) X-Greylist: delayed 00:06:39.128037 by SQLgrey- Received: from smtp107.mail.mud.yahoo.com (smtp107.mail.mud.yahoo.com [209.191.85.217]) by postgresql.org (Postfix) with SMTP id 348B49DC88D for ; Thu, 2 Mar 2006 20:37:03 -0400 (AST) Received: (qmail 7632 invoked from network); 3 Mar 2006 00:30:27 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.br; h=Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=rBXWX5Cxs+7DfoJbUDFu/ms2mXnLxKqBmFO8s4nAKkxkdBOoKUo7Ezuh6f4Ja+BU+dAGEKwMhJVAr2qjWcYE3U/8tOr2re/3QdzFi8t+xaPqHj7QJ6WP1Ttf7kpjXGX5U5rnixCl9ocCqyk6JTTbhSMzYdPkgX87K+/dJ1aVTHI= ; Received: from unknown (HELO ?10.0.0.1?) (hugo?sacramento@201.29.104.182 with plain) by smtp107.mail.mud.yahoo.com with SMTP; 3 Mar 2006 00:30:26 -0000 Message-ID: <44078E20.3010703@yahoo.com.br> Date: Thu, 02 Mar 2006 21:30:24 -0300 From: Hugo Sacramento User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: Retrieve Query References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-7; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.479 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479] X-Spam-Score: 0.479 X-Spam-Level: X-Archive-Number: 200603/14 X-Sequence-Number: 14795 I got jdbc source code and make it with follow change: org.postgresql.jdbc3.Jdbc3PreparedStatement.java: public String toString() { return preparedQuery.toString(preparedParameters); } Works fine. Achilleus Mantzios escreveu: > O Markus Schaber Ýãñáøå óôéò Feb 27, 2006 : > > >> Hi, Hugo, >> >> Hugo Sacramento wrote: >> >>> How do I to retrieve the string query prepared by a PreparedStatement?? >>> >>> ------------- >>> PreparedStatement stmt = con.prepareStatement("select * from abc where >>> x=?"); >>> stmt.setString(1, x); >>> System.out.println("My Prepared Query:" + stmt.toString()); >>> ------------ >>> >>> but it don't work. >>> >> There are at least two potential problems: >> >> - The statement is prepared server-side, and the parameters are sent >> separately (binding). Only the server has the "real" representation of >> the complete statement. So the prepared statement can only give an >> approximation, which is what pgjdbc does. >> >> - Most connection pooling and datasource mechanisms (e. G. in jboss) >> wrap your connection and all other classes (including the statement), >> but don't delegate the toString() method, so you'll only get something >> like "org.jboss.pool.wrappedStatement@4711". >> > > In jboss there is getUnderlyingStatement() method > so you could > > PreparedStatement st=... > ..... > org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement jst = > (org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement) st; > > org.postgresql.jdbc3.Jdbc3PreparedStatement pst = > (org.postgresql.jdbc3.Jdbc3PreparedStatement) jst.getUnderlyingStatement(); > > System.out.println(pst.toString()); > > >> HTH, >> Markus >> >> > > _______________________________________________________ Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora! http://br.acesso.yahoo.com