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