pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedRetrieve Query
4+ messages / 3 participants
[nested] [flat]
* Retrieve Query
@ 2006-02-24 17:39 Hugo Sacramento <hugo_sacramento@yahoo.com.br>
2006-02-27 10:38 ` Re: Retrieve Query Markus Schaber <schabi@logix-tt.com>
0 siblings, 1 reply; 4+ messages in thread
From: Hugo Sacramento @ 2006-02-24 17:39 UTC (permalink / raw)
To: pgsql-jdbc
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!
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Retrieve Query
2006-02-24 17:39 Retrieve Query Hugo Sacramento <hugo_sacramento@yahoo.com.br>
@ 2006-02-27 10:38 ` Markus Schaber <schabi@logix-tt.com>
2006-02-27 11:55 ` Re: Retrieve Query Achilleus Mantzios <achill@matrix.gatewaynet.com>
0 siblings, 1 reply; 4+ messages in thread
From: Markus Schaber @ 2006-02-27 10:38 UTC (permalink / raw)
To: Hugo Sacramento <hugo_sacramento@yahoo.com.br>; +Cc: pgsql-jdbc
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Retrieve Query
2006-02-24 17:39 Retrieve Query Hugo Sacramento <hugo_sacramento@yahoo.com.br>
2006-02-27 10:38 ` Re: Retrieve Query Markus Schaber <schabi@logix-tt.com>
@ 2006-02-27 11:55 ` Achilleus Mantzios <achill@matrix.gatewaynet.com>
2006-03-03 00:30 ` Re: Retrieve Query Hugo Sacramento <hugo_sacramento@yahoo.com.br>
0 siblings, 1 reply; 4+ messages in thread
From: Achilleus Mantzios @ 2006-02-27 11:55 UTC (permalink / raw)
To: Markus Schaber <schabi@logix-tt.com>; +Cc: Hugo Sacramento <hugo_sacramento@yahoo.com.br>; pgsql-jdbc
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Retrieve Query
2006-02-24 17:39 Retrieve Query Hugo Sacramento <hugo_sacramento@yahoo.com.br>
2006-02-27 10:38 ` Re: Retrieve Query Markus Schaber <schabi@logix-tt.com>
2006-02-27 11:55 ` Re: Retrieve Query Achilleus Mantzios <achill@matrix.gatewaynet.com>
@ 2006-03-03 00:30 ` Hugo Sacramento <hugo_sacramento@yahoo.com.br>
0 siblings, 0 replies; 4+ messages in thread
From: Hugo Sacramento @ 2006-03-03 00:30 UTC (permalink / raw)
To: pgsql-jdbc
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
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2006-03-03 00:30 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-02-24 17:39 Retrieve Query Hugo Sacramento <hugo_sacramento@yahoo.com.br>
2006-02-27 10:38 ` Markus Schaber <schabi@logix-tt.com>
2006-02-27 11:55 ` Achilleus Mantzios <achill@matrix.gatewaynet.com>
2006-03-03 00:30 ` Hugo Sacramento <hugo_sacramento@yahoo.com.br>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox