
Signature
This signature intentionally left blank.
>>>>How can I get the SQL statement which will be submitted by the
>>>>PreparedStatement to the database to execute?
[quoted text clipped - 33 lines]
> HTH,
> Ray
So java does not have a function which can tell me the SQL statement which
will be executed? In other languages like PowerBuilder, you can get the SQL
statement you are going to submit.
IchBin - 23 Feb 2006 20:34 GMT
>>>>> How can I get the SQL statement which will be submitted by the
>>>>> PreparedStatement to the database to execute?
[quoted text clipped - 37 lines]
> will be executed? In other languages like PowerBuilder, you can get the SQL
> statement you are going to submit.
That is because the SQL statement is embedded in the DataWindow object.

Signature
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Raymond DeCampo - 23 Feb 2006 20:47 GMT
> So java does not have a function which can tell me the SQL statement which
> will be executed? In other languages like PowerBuilder, you can get the SQL
> statement you are going to submit.
I do not know how many other ways I can tell you that once you are at
the PreparedStatement stage you are past the SQL portion of the program.
There is nothing in the standard APIs to help you. So start looking in
the documentation specific to your driver or start implementing it yourself.
Ray

Signature
This signature intentionally left blank.
steve - 23 Feb 2006 22:52 GMT
>>>>> How can I get the SQL statement which will be submitted by the
>>>>> PreparedStatement to the database to execute?
[quoted text clipped - 37 lines]
> will be executed? In other languages like PowerBuilder, you can get the SQL
> statement you are going to submit.
basically you build an sql string and submit it to the database.
then you add in your paramaters etc and submit it to the database..
the database parses and compiles the statement internally. ( or it may even
have a pre-parsed, pre-compiled previous version squirreled away(oracle))
if you want to see the sql "at the database end" after the statement has been
assembled, then you CAN use java, but you must query the database tools to do
it.
the only other way i can think would be to re-write your sql routines, so
that you log the statement & params BEFORE they are sent to the database.
it depends on the database you are using.
Thomas Kellerer - 24 Feb 2006 16:55 GMT
JY wrote on 23.02.2006 21:08:
> So java does not have a function which can tell me the SQL statement which
> will be executed? In other languages like PowerBuilder, you can get the SQL
> statement you are going to submit.
As the Statement class is implemented by the driver it's up to the database
vendor to implement such functionality. This has nothing to do with Java itself.
Actually there are drivers out there that will print everything when calling
toString() on a Statement or a PreparedStatement (e.g. the Postgres driver IIRC)
It's been some time since I have used PowerBuilder but I cannot recall a way to
get that information for statements using bind variables either.
Thomas