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

Try DataDirect Drivers Now
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.
Note: The following examples are drawn from Microsoft SQL Server and DB2 use cases. However, they inform the implementation of DataDirect Spy for most Progress DataDirect drivers.

Example on Windows:

The following example uses the JDBC Driver Manager to connect to Microsoft SQL Server while enabling DataDirect Spy:
Class.forName("com.ddtek.jdbc.sqlserver.SQLServerDriver");
Connection conn = DriverManager.getConnection
   ("jdbc:datadirect:sqlserver://Server1:1433;DatabaseName=Test;
User=admin;Password=secret;
   SpyAttributes=(log=(filePrefix)C:\\temp\\spy_;linelimit=80;logTName=yes;
   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=(filePrefix)C:\\temp\\spy_.
Using this example, DataDirect Spy loads the SQL Server driver and logs all JDBC activity to the spy_x.log file located in the C:\temp directory (log=(filePrefix)C:\\temp\\spy_), where x is an integer that increments by 1 for each connection on which the prefix is specified. The spy_x.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).

Example on UNIX:

The following code example uses the JDBC Driver Manager to connect to DB2 while enabling DataDirect Spy:
Class.forName("com.ddtek.jdbc.db2.DB2Driver");
Connection conn = DriverManager.getConnection
   ("jdbc:datadirect:db2://Server1:50000;DatabaseName=Test;
User=TEST;Password=secret;
   SpyAttributes=(log=(filePrefix)/tmp/spy_;logTName=yes;timestamp=yes)");
Using this example, DataDirect Spy loads the DB2 driver and logs all JDBC activity to the spy_x.log file located in the /tmp directory (log=(filePrefix)/tmp/spy_), where x is an integer that increments by 1 for each connection on which the prefix is specified. The spy_x.log file includes the name of the current thread (logTName=yes) and a timestamp on each line in the log (timestamp=yes).