File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes monitoring JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "monitoring JDBC" Watch "monitoring JDBC" New topic

monitoring JDBC

christoph weingarten
Ranch Hand

Joined: Oct 10, 2002
Posts: 39
is there any way to monitor the JDBC-datastream between a db-server and a java-client?
i'm using jconnect5.5 to connect to a sybase-db.
does anybody know a good moitoring-tool?
Loren Rosen
Ranch Hand

Joined: Feb 12, 2003
Posts: 156
Do you really want to look at the protocol between the JDBC driver and the server, or do really want to know what queries are being sent?
To log the queries, log4j has a logging facility, which has some limitations. Various people have tried to fix these, e.g. see here
and here
... a google search for 'jdbc log4j' might find even more.
There's also this article from IBM developer works.
If you're using some O/R mapping tool, or an app server, it may have facilities for doing the logging. Also, your database server can probably be set-up to log queries.
As for lower-level protocol logging, most JDBC drivers interact with the server in the same way as any other client. The tools to look at the interaction are specific to the DBMS.
Sean Sullivan
Ranch Hand

Joined: Sep 09, 2001
Posts: 427
Also, java.sql.DriverManager has a method called "setLogWriter"
christoph weingarten
Ranch Hand

Joined: Oct 10, 2002
Posts: 39
Thanks! I solved the problem with some simple System.out.println's...
I agree. Here's the link:
subject: monitoring JDBC
It's not a secret anymore!