Re: Getting query SQL from a JDBC PreparedStatement
- From: "joeNOSPAM@xxxxxxx" <joe.weinstein@xxxxxxxxx>
- Date: 5 Jun 2006 13:57:26 -0700
Larry Coon wrote:
Using Sybase JConnect's implementation of JDBC in Java 1.5.
For logging/debug purposes, I want to get the SQL query text from
a PreparedStatement (which is a SybPreparedStatement in this
implementation). Something like:
String query = "select xxx from mytable where aaa = ? and bbb = ?";
SybPreparedStatement s = (SybPreparedStatement)
connection.prepareStatement(query);
s.setString(1, "sarg1");
s.setString(2, "sarg2");
------
At this point I want to get the query text, i.e.:
select xxx from mytable where aaa = "sarg1" and bbb = "sarg2"
From the prepared statement. toString() doesn't return the query,
it returns a string like:
com.sybase.jdbc2.jdbc.SybPreparedStatement@1f630dc
And I see no other methods that return a String. What am I missing
here?
Nothing. There is no standard JDBC or sybase-specific
method or variable which exposes the SQL you gave the
connection when asking for a PreparedStatement. The
statement certainly does have a version of the string,
possibly modified for the JDBC SQL escapes, but you
would have to decompile, alter, and recompile, and run
your modified driver to be able to get it programmatically.
Joe Weinstein at BEA Systems
.
- Follow-Ups:
- Re: Getting query SQL from a JDBC PreparedStatement
- From: Larry Coon
- Re: Getting query SQL from a JDBC PreparedStatement
- References:
- Getting query SQL from a JDBC PreparedStatement
- From: Larry Coon
- Getting query SQL from a JDBC PreparedStatement
- Prev by Date: Re: Getting query SQL from a JDBC PreparedStatement
- Next by Date: crazy pooling jdbc driver on msaccess
- Previous by thread: Re: Getting query SQL from a JDBC PreparedStatement
- Next by thread: Re: Getting query SQL from a JDBC PreparedStatement
- Index(es):
Relevant Pages
|