skip to main content
Tracking JDBC Calls : Enabling DataDirect Spy : Using the JDBC Driver Manager
 

Using the JDBC Driver Manager

The SpyAttributes connection property allows you to specify a semi-colon separated list of DataDirect Spy attributes (see DataDirect Spy Attributes). The format for the value of the SpyAttributes property is:
(spy_attribute[;spy_attribute]...)
where spy_attribute is any valid DataDirect Spy attribute. See DataDirect Spy Attributes for a list of supported attributes.

Example on Windows

The following example uses the JDBC Driver Manager to connect to Oracle while enabling DataDirect Spy:
Class.forName("com.ddtek.jdbc.openaccess.OpenAccessDriver");
Connection conn = DriverManager.getConnection ("jdbc:openaccess://QANT:4003;user=TEST;password=secret;
SpyAttributes=(log=(file)C:\\temp\\spy.log;
linelimit=80;logTName=yes;timestamp=yes)");
Using this example, DataDirect Spy would load the JDBC driver and log all JDBC activity to the spy.log file located in the C:\temp directory (log=(file)C:\temp\spy.log). The spy.log file logs a maximum of 80 characters on each line (linelimit=80) and includes the name of the current thread (logTName=yes) and a timestamp on each line in the log (timestamp=yes).
Note: If coding a path on Windows to the log file in a Java string, the backslash character (\) must be preceded by the Java escape character, a backslash. For example: log=(file)C:\\temp\\spy.log.

Example on Linux and UNIX:

The following code example uses the JDBC Driver Manager to connect to a data source while enabling DataDirect Spy:
Class.forName("com.ddtek.jdbc.openaccess.OpenAccessDriver");
Connection conn = DriverManager.getConnection
("jdbc:openaccess://user=TEST;password=secret;
SpyAttributes=(log=(file)C:/temp/spy.log;
linelimit=80;logTName=yes;timestamp=yes)");
Using this example, DataDirect Spy would load the JDBC driver and log all JDBC activity to the spy.log file located in the /tmp directory (log=(file)/tmp/spy.log). The spy.log file includes the name of the current thread (logTName=yes) and a timestamp on each line in the log (timestamp=yes).