Troubleshooting InterClient Programs

From InterBase

Go Up to Programming with JDBC

This section covers troubleshooting InterClient installation and debugging applications.

Handling Installation Problems

Call interbase.interclient.InstallTest to test an InterClient installation. InstallTest provides two static methods for testing the installation. A static main is provided as a command line test that prints to System.out. main() uses the other public static methods that test specific features of the installation. These methods can be used by a GUI application as they return strings, rather than writing the diagnostics to System.out as main() does. InstallTest allows you to:

  • determine InterClient driver version information
  • determine installed packages
  • check basic network configuration
  • test making a connection directly without the DriverManager with driver.connect()
  • test making a connection with DriverManager.getConnection()
  • get SQL Exception error messages

Debugging your Application

You can tailor your own driver instances by using a class called interbase.interclient.Monitor. This is a public InterClient extension to JDBC. The Monitor class contains user-configurable switches that enable you to call a method and trace what happens on a per-driver basis. Types of switches that you can enable include: enableDriverTrace, enableConnectionTrace, enableStatementTrace, and so forth.

Every driver instance has one and only one monitor instance associated with it. The initial monitor for the default driver instance that is implicitly registered with the DriverManager has no logging/tracing enabled. Enabling tracing for the default driver is not recommended. However, if you create your own driver instance, you can tailor the tracing and logging for your driver without affecting the default driver registered with the DriverManager.

If you want to use the Monitor to trace connections and statements, you must create the original objects using the connect() method of the tailored driver. You cannot create a connection with DriverManager.getConnection() method and then try to trace that connection. Since tracing is disabled for the default driver, there will be no data.

The following example shows calls to getMonitor() trace methods:

//Open the driver manager's log stream
//Create the driver object
java.sql.Driver icDriver = new interbase.interclient.Driver();
//Trace method invocations by printing messages to this monitor's
//trace stream
((interbase.interclient.Driver)icDriver).getMonitor().enableAllTraces (true);

After running the program and executing some SQL statements, you can print out the trace messages associated with the driver, connection, and statement methods. The tracing output distinguishes between implicit calls, such as the garbage collector or InterClient driver calling close() versus user-explicit calls. This can be used to test application code, since it would show if result sets or statements aren't being cleaned up when they should.

Advance To: