Using the JDBC DriverManager
- Last Updated: June 13, 2019
- 2 minute read
- DataDirect Connectors
- JDBC
- Aha! 6.0
- Amazon Redshift 6.0
- Apache Cassandra 6.0
- Apache Hive 6.0
- Apache Spark SQL 6.0
- Atlassian Jira 6.0
- Autonomous REST Connector 6.0
- Cloudera Impala 5.1
- + 24
The SpyAttributes connection property allows you to specify a semi-colon separated list of 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.
Windows example
The following example uses the JDBC Driver Manager to connect to Oracle while enabling DataDirect Spy:
Class.forName("com.ddtek.jdbc.oracle.OracleDriver");
Connection conn = DriverManager.getConnection
("jdbc:datadirect:oracle://Server3:1521;SID=ORCL;
User=User123;Password=secret;
SpyAttributes=(log=(filePrefix)C:\\temp\\spy_;linelimit=80;logTName=yes;
timestamp=yes)");
log=(filePrefix)C:\\temp\\spy_.Using this example, DataDirect Spy loads the 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).
UNIX example
The following code example uses the JDBC Driver Manager to connect to Oracle while enabling DataDirect Spy:
Class.forName("com.ddtek.jdbc.oracle.OracleDriver");
Connection conn = DriverManager.getConnection
("jdbc:datadirect:oracle://server:1521;SID=ORCL;
User=User123;Password=secret;
SpyAttributes=(log=(filePrefix)/tmp/spy_;logTName=yes;timestamp=yes)");
Using this example, DataDirect Spy loads the 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).