By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,232 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,232 IT Pros & Developers. It's quick & easy.

Logging dynamic SQL with query params

P: n/a
Hi All,

we're new to DB2 (using Express-C on Windows). We'd like to monitor the
SQL that Hibernate (a Java ORM) generates, along with query params. It
was quite simple to do so with MySQL, but we haven't found a way to do
that with DB2.
This is how far we got:
create event monitor sqlmonitor for statements write to file
'f:\tmp\db2sql'
set event monitor sqlmonitor state = 1
.... issue some sql ...
db2evmon -db minibar -evm sqlmonitor >sql.txt
grep "Text" sql.txt

This is quite inconvenient, and does not give us query params (we could
get the parameterless statements from Hibernate's own log in a much
simpler way).
It seems we're using the wrong tool - but which one is the right one?

TIA,
Kofa

Aug 7 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
we're new to DB2 (using Express-C on Windows). We'd like to monitor the
SQL that Hibernate (a Java ORM) generates, along with query params.
To answer my own question: the JDBC driver can be set to trace
commands.
http://www-128.ibm.com/developerwork...m-0506fechner/

<blush>Sorry for the noise</blush>

Kofa

Aug 7 '06 #2

P: n/a

kofa wrote:
we're new to DB2 (using Express-C on Windows). We'd like to monitor the
SQL that Hibernate (a Java ORM) generates, along with query params.

To answer my own question: the JDBC driver can be set to trace
commands.
http://www-128.ibm.com/developerwork...m-0506fechner/

<blush>Sorry for the noise</blush>

Kofa
Still not good enough.
Here's an excerpt from the log:
[ibm][db2][jcc][Time:1155024677451][Thread:main][Connection@c9d92c]
prepareStatement (select productimp_.id, productimp_.active as
active6_, productimp_.code as code6_, productimp_.description as
descript4_6_, productimp_.stock as stock6_, productimp_.adHocPrice as
adHocPrice6_, productimp_.costPrice as costPrice6_,
productimp_.category as category6_, productimp_.supplier as supplier6_,
productimp_.type as type6_ from Product productimp_ where
productimp_.id=?) called
[ibm][db2][jcc][Time:1155024677451][Thread:main][Connection@c9d92c]
prepareStatement () returned PreparedStatement@106dc2d
[ibm][db2][jcc][Time:1155024677451][Thread:main][PreparedStatement@106dc2d]
setLong (1, 522) called
[ibm][db2][jcc][Time:1155024677451][Thread:main][PreparedStatement@106dc2d]
executeQuery () called

Not very easy to read (params shown on a separate line, in an even more
verbose fashion than we could get directly from Hibernate). The same
thing with MySQL:
Query select productimp_.id, productimp_.active as active6_,
productimp_.code as code6_, productimp_.description as descript4_6_,
productimp_.stock as stock6_, productimp_.adHocPrice as adHocPrice6_,
productimp_.costPrice as costPrice6_, productimp_.category as
category6_, productimp_.supplier as supplier6_, productimp_.type as
type6_ from Product productimp_ where productimp_.id=522

Any ideas (without costly third-party tools)?

TIA,
Kofa

Aug 8 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.