skip to main content
Tracking JDBC Calls : Enabling DataDirect Spy : Using JDBC Data Sources
 

Using JDBC Data Sources

The JDBC Client implements the following JDBC features:
JNDI for Naming Databases
Connection Pooling
JTA
You can use DataDirect Spy to track JDBC calls made by a running application with any of these features. The com.ddtek.jdbcx.OpenAccess.datasource.OpenAccessDataSource class supports setting a semi-colon-separated list of DataDirect Spy attributes (see DataDirect Spy Attributes).
See Configuring JDBC Data Sources for more information about configuring data sources.

Example on Windows

The following example creates a JDBC data source for the JDBC Client, which enables DataDirect Spy.
...
OpenAccessDataSource sds=new OpenAccessDataSource():
sds.setServerName("MyServer");
sds.setPortNumber(1234);
sds.setSpyAttributes("log=(file)C:C:/temp/spy.log;logIS=yes;logTName=yes");
Connection conn=sds.getConnection("scott","tiger");
...
Using this example, DataDirect Spy would load the JDBC Client and log all JDBC activity to the spy.log file located in the C:\temp directory (log=(file)C:\temp\spy.log). In addition to regular JDBC activity, the spy.log file also logs activity on InputStream and Reader objects (logIS=yes). It also includes the name of the current thread (logTName=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;logIS=yes;logTName=yes".

Example on Linux and UNIX:

The following example creates a JDBC data source for the JDBC Client, which enables DataDirect Spy.
...
OpenAccessDataSource sds=new OpenAccessDataSource():
sds.setServerName("MyServer");
sds.setPortNumber(1234);
sds.setSpyAttributes("log=(file)C:/tmp/spy.log;logIS=yes;logTName=yes");
Connection conn=sds.getConnection("TEST","secret");
...
Using this example, DataDirect Spy would load the JDBC Client 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).