views:

42

answers:

2

I am currently writing an application for monitoring SQL queries produced by a web application. I am interested in monitoring the SQL queries being sent by a given application passively. That is, I don't want a proxy - instead I want to run the application to sit separate of the web application / database, and simply read the SQL queries being executed by the application. Is there anyway to do this with Java/C++?

A: 

You can use the log from the mysql database itself. You can have a program read that log file and display it. You say C++ or java, but something with good string handling would probly be easier. Perl maybe?

http://dev.mysql.com/doc/refman/5.0/en/query-log.html

Chris H
+1  A: 

Which database are you using? SQL Server Profiler allows you to monitor database activity in realtime, filtering SQL statements according to user, etc.

Also, why are you trying to avoid using a proxy implementation? You could use a connection pool such as C3P0 and enable appropriate logging in order to capture all SQL executed. I can imagine the performance impact would be negligable.

Adamski
Well I was hoping my tool would be independent of the application. A user can run it, and start monitoring instead of having to change parts of their code. But I suppose a proxy would be the easiest to implement - any recommendations how to implement a proxy?
Louis