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