11 Troubleshooting : Troubleshooting Your Application

Troubleshooting Your Application
To help you troubleshoot any problems that occur with your application, you can use DataDirect Spy to log detailed information about calls issued by the drivers on behalf of your application. When you enable DataDirect Spy for a connection, you can customize DataDirect Spy logging by setting one or multiple options. See Chapter 8 “Tracking JDBC Calls with DataDirect Spy™” for information about using DataDirect Spy and instructions on enabling and customizing logging.
Turning On and Off DataDirect Spy™ Logging
Once DataDirect Spy logging is enabled for a connection, you can turn on and off the logging at runtime using the setEnableLogging() method in the com.ddtek.jdbc.extensions.ExtLogControl interface. When DataDirect Spy logging is enabled, all Connection objects returned to an application provide an implementation of the ExtLogControl interface.
For example, the following code turns off logging using setEnableLogging(false):
import com.ddtek.jdbc.extensions.*
 
// Get Database Connection
Connection con = DriverManager.getConnection
("jdbc:datadirect:sqlserver://server1:1433;User=TEST;Password=secret;
SpyAttributes=(log=(file)/tmp/spy.log");
 
((ExtLogControl) con).setEnableLogging(false);
...
The setEnableLogging() method only turns on and off logging if DataDirect Spy logging has already been enabled for a connection; it does not set or change DataDirect Spy attributes. See “Enabling DataDirect Spy™” for information about enabling and customizing DataDirect Spy logging.
DataDirect Spy™ Log Example
This section provides information to help you understand the content of your own DataDirect Spy logs. For example, suppose your application executes the following code and performs some operations:
Class.forName("com.ddtek.jdbc.sqlserver.SQLServerDriver");
DriverManager.getConnection("jdbc:datadirect:sqlserver:// nc-myserver\
\sqlserver2005;useServerSideUpdatableCursors=true;resultsetMetaDataOptions=1;sendStringParametersAsUnicode=true;alwaysReportTriggerResults=false;
spyAttributes=(log=(file)c:\\temp\\spy.log)","test04", "test04");
The log file generated by DataDirect Spy would look similar to the following example. Notes provide explanations for the referenced text.
spy>> Connection[1].getMetaData()
spy>> OK (DatabaseMetaData[1])
 
spy>> DatabaseMetaData[1].getURL()
spy>> OK (jdbc:datadirect:sqlserver://nc-myserver\sqlserver2005:1433;CONNECTIONRETRYCOUNT=5;RECEIVESTRINGPARAMETERTYPE=nvarchar;ALTERNATESERVERS=;DATABASENAME=;PACKETSIZE=16;INITIALIZATIONSTRING=;ENABLECANCELTIMEOUT=false;BATCHPERFORMANCEWORKAROUND=false;AUTHENTICATIONMETHOD=auto;SENDSTRINGPARAMETERSASUNICODE=true;LOGINTIMEOUT=0;WSID=;SPYATTRIBUTES=(log=(file)c:\temp\spy.log);RESULTSETMETADATAOPTIONS=1;ALWAYSREPORTTRIGGERRESULTS=false;TRANSACTIONMODE=implicit;USESERVERSIDEUPDATABLECURSORS=true;SNAPSHOTSERIALIZABLE=false;JAVADOUBLETOSTRING=false;SELECTMETHOD=direct;LOADLIBRARYPATH=;CONNECTIONRETRYDELAY=1;INSENSITIVERESULTSETBUFFERSIZE=2048;MAXPOOLEDSTATEMENTS=0;DESCRIBEPARAMETERS=noDescribe;CODEPAGEOVERRIDE=;NETADDRESS=000000000000;PROGRAMNAME=;LOADBALANCING=false;HOSTPROCESS=0) 1
 
spy>> DatabaseMetaData[1].getDriverName()
spy>> OK (SQLServer)
 
spy>> DatabaseMetaData[1].getDriverVersion()
spy>> OK (3.60.0 (000000.000000.000000))
 
spy>> DatabaseMetaData[1].getDatabaseProductName()
spy>> OK (Microsoft SQL Server)
 
spy>> DatabaseMetaData[1].getDatabaseProductVersion()
spy>> OK (Microsoft SQL Server Yukon - 9.00.1399)
 
spy>> Connection Options : 2
spy>> CONNECTIONRETRYCOUNT=5
spy>> RECEIVESTRINGPARAMETERTYPE=nvarchar
spy>> ALTERNATESERVERS=
spy>> DATABASENAME=
spy>> PACKETSIZE=16
spy>> INITIALIZATIONSTRING=
spy>> ENABLECANCELTIMEOUT=false
spy>> BATCHPERFORMANCEWORKAROUND=false
spy>> AUTHENTICATIONMETHOD=auto
spy>> SENDSTRINGPARAMETERSASUNICODE=true
spy>> LOGINTIMEOUT=0
spy>> WSID=
spy>> SPYATTRIBUTES=(log=(file)c:\temp\spy.log)
spy>> RESULTSETMETADATAOPTIONS=1
spy>> ALWAYSREPORTTRIGGERRESULTS=false
spy>> TRANSACTIONMODE=implicit
spy>> USESERVERSIDEUPDATABLECURSORS=true
spy>> SNAPSHOTSERIALIZABLE=false
spy>> JAVADOUBLETOSTRING=false
spy>> SELECTMETHOD=direct
spy>> LOADLIBRARYPATH=
spy>> CONNECTIONRETRYDELAY=1
spy>> INSENSITIVERESULTSETBUFFERSIZE=2048
spy>> MAXPOOLEDSTATEMENTS=0
spy>> DESCRIBEPARAMETERS=noDescribe
spy>> CODEPAGEOVERRIDE=
spy>> NETADDRESS=000000000000
spy>> PROGRAMNAME=
spy>> LOADBALANCING=false
spy>> HOSTPROCESS=0
 
spy>> Driver Name = SQLServer 3
 
spy>> Driver Version = 3.60.0 (000000.000000.000000) 4
 
spy>> Database Name = Microsoft SQL Server 5
 
spy>> Database Version = Microsoft SQL Server Yukon - 9.00.1399 6
 
spy>> Connection[1].getWarnings()
spy>> OK 7
 
spy>> Connection[1].createStatement
spy>> OK (Statement[1])
 
spy>> Statement[1].executeQuery(String sql)
spy>> sql = select empno,ename,job from emp where empno=7369
spy>> OK (ResultSet[1]) 8
 
spy>> ResultSet[1].getMetaData()
spy>> OK (ResultSetMetaData[1]) 9
 
spy>> ResultSetMetaData[1].getColumnCount()
spy>> OK (3)10
 
spy>> ResultSetMetaData[1].getColumnLabel(int column)
spy>> column = 1
spy>> OK (EMPNO)11
 
spy>> ResultSetMetaData[1].getColumnLabel(int column)
spy>> column = 2
spy>> OK (ENAME)12
 
spy>> ResultSetMetaData[1].getColumnLabel(int column)
spy>> column = 3
spy>> OK (JOB)13
 
spy>> ResultSet[1].next()
spy>> OK (true)14
 
spy>> ResultSet[1].getString(int columnIndex)
spy>> columnIndex = 1
spy>> OK (7369) 15
 
spy>> ResultSet[1].getString(int columnIndex)
spy>> columnIndex = 2
spy>> OK (SMITH) 16
 
spy>> ResultSet[1].getString(int columnIndex)
spy>> columnIndex = 3
spy>> OK (CLERK) 17
 
spy>> ResultSet[1].next()
spy>> OK (false) 18
 
spy>> ResultSet[1].close()
spy>> OK 19
 
spy>> Connection[1].close()
spy>> OK 20

1
The combination of the URL specified by the application and the default values of all connection properties not specified.

2
The combination of the connection properties specified by the application and the default values of all connection properties not specified.

3
The name of the driver.

4
The version of the driver.

5
The name of the database server to which the driver connects.

6
The version of the database to which the driver connects.

7
The application checks to see if there are any warnings. In this example, no warnings are present.

8
The statement select empno,ename,job from emp where empno=7369 is created.

9
Some metadata is requested.

10
Some metadata is requested.

11
Some metadata is requested.

12
Some metadata is requested.

13
Some metadata is requested.

14
The first row is retrieved and the application retrieves the result values.

15
The first row is retrieved and the application retrieves the result values.

16
The first row is retrieved and the application retrieves the result values.

17
The first row is retrieved and the application retrieves the result values.

18
The application attempts to retrieve the next row, but only one row was returned for this query.

19
After the application has completed retrieving result values, the result set is closed.

20
The application finishes and disconnects.