3 messages in com.mysql.lists.javaRe: Using stack traces within profileSQL| From | Sent On | Attachments |
|---|---|---|
| Kevin A. Burton | 13 Sep 2004 12:09 | |
| Mark Matthews | 13 Sep 2004 12:46 | |
| Kevin A. Burton | 13 Sep 2004 12:51 |
| Subject: | Re: Using stack traces within profileSQL![]() |
|---|---|
| From: | Mark Matthews (ma...@mysql.com) |
| Date: | 09/13/2004 12:46:54 PM |
| List: | com.mysql.lists.java |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Kevin A. Burton wrote:
Feature suggestion...
In our OM layer I've added a stack trace profile capability to our prepared statements.
What I do is use the new JDK 1.4 getStackTrace method to determine the caller.
if ( USE_INLINE_STACK ) {
Exception e = new Exception( "QUERY DEBUG EXCEPTION (IGNORE)" );
stackframe = e.getStackTrace()[2].toString(); }
Then I create my prepared statements with
" -- " + stackframe
This way when I enable profileSQL I get
SELECT * FROM FOO WHERE ID = ? -- Test.java:101
Which is VERY nice.
Note that this needs to be done AFTER the SQL stmt or the MySQL query cache won't be used. Also since the immediate caller is almost always the same then it can still be cached.
I want to get this into the driver so that I can remove it from my OM layer since not all SQL stmts would be logged.
Note that in your situation you might need a configuration option about where to start including the stacktrace frame. Since the driver is often included within OM layers you might want to have a regexp method match so that you can start to dump from com.my.company.
Kevin
Kevin,
Connector/J 3.1.x already has this feature. Here's some example output:
Mon Sep 13 14:45:53 CDT 2004 INFO: Profiler Event: [QUERY] at at testsuite.simple.MiniAdminTest.testUrlConstructor(MiniAdminTest.java:89) duration: 10 ms, connection-id: 0, statement-id: 999, resultset-id: 0, message: SET NAMES latin1
-Mark
- -- Mr. Mark Matthews MySQL AB, Software Development Manager, J2EE and Windows Platforms Office: +1 708 332 0507 www.mysql.com
MySQL Guide to Lower TCO http://www.mysql.com/it-resources/white-papers/tco.php -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFBRflEtvXNTca6JD8RAuQvAKCTV8K3mtdqoB3227KdGzfH1H4W2ACgnlsA 8a32xzxaLWw21+GhQEXbPss= =Cr9N -----END PGP SIGNATURE-----




