All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class interbase.interclient.Monitor

java.lang.Object
   |
   +----interbase.interclient.Monitor

public final class Monitor
extends Object
InterClient Extension

The Monitor class is an InterClient extension for monitoring JDBC calls.

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

Here's how to enable the monitor for the default driver registered with the driver manager.

 import java.sql.*;
 Class.forName ("interbase.interclient.Driver");
 DriverManager.getConnection ("jdbc:interbase://server//database-dir/atlas.gdb", 
                              "sysdba", "masterkey");
 java.sql.Driver registeredDriver = DriverManager.getDriver ("jdbc:interbase:");
 interbase.interclient.Monitor monitor = 
   ((interbase.interclient.Driver) registeredDriver).getMonitor ();
 monitor.enableAllTraces (true);
 monitor.setTraceStream (System.out);
 DriverManager.getConnection ("jdbc:interbase://server//database-dir/atlas.gdb", 
                              "sysdba", "masterkey");
 
Here's how to enable the monitor for an unregistered driver instance.
 import java.sql.*;
 interbase.interclient.Driver unregisteredDriver = new interbase.interclient.Driver ();
 interbase.interclient.Monitor monitor = unregisteredDriver.getMonitor ();
 monitor.setTraceStream (System.out);
 monitor.enableAllTraces (true);
 interbase.interclient.ConnectionProperties p = new interbase.interclient.ConnectionProperties ();
 p.setUser ("sysdba", "masterkey");
 Connection c = unregisteredDriver.connect ("jdbc:interbase://server//databases/atlas.gdb", p);
 
Here's how to use the Monitor with JBuilder.
 import java.sql.*;
 import borland.jbcl.dataset.*;
 borland.jbcl.dataset.Database database = new Database ();
 database.setConnection (
   new ConnectionDescriptor ("jdbc:interbase://server//databases/atlas.gdb",
                             "sysdba",
                             "masterkey", 
                             false, 
                             "interbase.interclient.Driver"));
 interbase.interclient.Driver registeredDriver = 
   (interbase.interclient.Driver) DriverManager.getDriver ("jdbc:interbase:");
 interbase.interclient.Monitor monitor = registeredDriver.getMonitor ();
 monitor.enableAllTraces (true);
 monitor.setTraceStream (System.out);
 borland.jbcl.dataset.QueryDataSet queryDataSet = new QueryDataSet ();
 queryDataSet.setQuery (new QueryDescriptor (database, "select * from employee", null, true, false));
 
Note: It is good software engineering practice to declare InterClient object instances as interface instances (java.sql.Driver, java.sql.Connection, java.sql.Statement, java.sql.ResultSet, etc...) rather than class instances (interbase.interclient.Driver, interbase.interclient.Connection, interbase.interclient.Statement, interbase.interclient.ResultSet, etc...). In this way, use of InterClient extensions to JDBC must be accompanied by an explicit cast, eg.
 ((interbase.interclient.Driver) d).getExpirationDate ();
 
thereby resulting in more portable code.

See Also:
getMonitor

Method Index

 o enableAllTraces(boolean)
Trace method invocations by printing messages to this monitor's trace stream.
 o enableConnectionTrace(boolean)
Trace connection and database meta data method invocations by printing messages to this monitor's trace stream.
 o enableDriverTrace(boolean)
Trace driver method invocations by printing messages to this monitor's trace stream.
 o enableResultSetTrace(boolean)
Trace result set method invocations by printing messages to this monitor's trace stream.
 o enableStatementTrace(boolean)
Trace statement method invocations by printing messages to this monitor's trace stream.
 o getTraceStream()
Get the logging/tracing PrintStream that is used by the monitor for a driver instance.
 o println(String)
Print a message to the monitor's trace stream.
 o setTraceStream(PrintStream)
Set the logging/tracing PrintStream that is used by the monitor for a driver instance.

Methods

 o enableDriverTrace
  public synchronized void enableDriverTrace(boolean enable) throws SQLException
Trace driver method invocations by printing messages to this monitor's trace stream.

 o enableConnectionTrace
  public synchronized void enableConnectionTrace(boolean enable) throws SQLException
Trace connection and database meta data method invocations by printing messages to this monitor's trace stream.

 o enableStatementTrace
  public synchronized void enableStatementTrace(boolean enable) throws SQLException
Trace statement method invocations by printing messages to this monitor's trace stream.

 o enableResultSetTrace
  public synchronized void enableResultSetTrace(boolean enable) throws SQLException
Trace result set method invocations by printing messages to this monitor's trace stream.

 o enableAllTraces
  public synchronized void enableAllTraces(boolean enable) throws SQLException
Trace method invocations by printing messages to this monitor's trace stream.

 o setTraceStream
  public synchronized void setTraceStream(PrintStream traceStream)
Set the logging/tracing PrintStream that is used by the monitor for a driver instance.

Parameters:
traceStream - The new tracing PrintStream.
 o getTraceStream
  public synchronized PrintStream getTraceStream()
Get the logging/tracing PrintStream that is used by the monitor for a driver instance.

Returns:
The logging/tracing PrintStream; if disabled, is null.
 o println
  public synchronized void println(String message)
Print a message to the monitor's trace stream.

Parameters:
message - A trace message to print to the trace stream.

All Packages  Class Hierarchy  This Package  Previous  Next  Index