Monitoring database connections

DataGateway provides a JDBC monitoring class which can monitor or manipulate JDBC traffic. JBuilder provides a user interface, invoked from Tools|JDBC Monitor, to work with this class at design time. For information on using this class at run time, see Using the JDBC Monitor in a running application.

JDBC Monitor will monitor any JDBC driver (i.e., any subclass of java.sql.Driver) while they are in use by JBuilder. However, it works best, and is most informative with, Borland's DataGateway JDBC drivers.

JDBC Monitor controls

The JDBC Monitor can be used during the design process or while debugging a JBuilder application to display trace output from the driver. The three controls that enable you to set up JDBC Monitor are:

More information on the JDBC Monitor can be found in the Borland DataGateway help system.

The Source control

An instance of the JDBC Monitor can only display output from one SQL driver type at a time. To change the monitor window from one source to another, select Source in the main Monitor window. Select the appropriate check box for the source you want to monitor. Notice that the three check boxes are mutually exclusive.

Users who wish to monitor more than one source must bring up another instance of the monitor window.

The following table describes the output you will see in the JDBC Monitor depending on which source is selected. In this table and in this document, Local and Bridge are synonymous and Remote and Broker are synonymous. The log output from DataGateway is quite different from the output from JDBC.

Driver Class Output InterceptedDescription
java.sql.DriverDriverManager.getLogStream() Standard JDBC driver class. The logStream is supported by the single driver Manager, so there is just one log stream for all of the JDBC drivers running under a VM.
borland.jdbc.Bridge.LocalDriver borland.jdbc.Bridge.Monitor A monitor is a streamable output which can be attached at one of two levels:
  • At the driver level, the monitor displays all output for all instances of the LocalDriver running under the VM.

  • At the URL level, the monitor displays output for all connections to a given URL (the equivalent of a Borland Database Engine alias) running under the VM.
borland.jdbc.Broker.RemoteDriver borland.jdbc.Broker.Monitor The Broker monitor works similarly to the Bridge monitor, but for remote connections. To use the remote monitor, you must first specify a server name where the Borland Broker is running. You may then attach the monitor at one of two levels:
  • For a given server, the monitor displays all output for connections to the RemoteDriver running under the VM.

  • At the individual URL level, the monitor displays the output for a given server/alias combination running under the VM.

For more information on JDBC Monitor, consult Borland's DataGateway Online User's Guide, available from the DataGateway group when DataGateway is installed.

The Traces control

Selecting the Traces control displays a menu of options for selecting the type of tracing you can enable. This control is only useful when tracing a Borland Driver (either Local or Remote). The trace control offers five options. The description of each option is provided by Borland DataGateway.

You can select to display any combination of these five trace types, depending on the type and detail of information you want to display.

The Output control

Selecting the Output control displays a menu of options for handling the current contents of the data stream.

Using the JDBC Monitor in a running application

To monitor database connections at run time, a MonitorButton or a MonitorPanel must be included with the application. MonitorButton is a Java bean which allows you to run the JDBC monitor against a running application. To do so, the instance of the JDBC monitor in use must be brought up by the application. The MonitorButton provides an API so that you can specify which connection to monitor while in design mode. An instance of the JDBC Monitor brought up from the IDE will only monitor database activities during design time.

The MonitorPanel can be used to place the monitor directly on a form. It has the same properties as the MonitorButton.

Adding the MonitorButton to the Palette

The MonitorButton can be put on the Component Palette by following these steps:

  1. Right-click on the Component Palette, select Properties to bring up the Palette Properties dialog.

  2. Select the Data Express page on the Pages page.

  3. Select the Add From Archive page.

  4. Enter or browse to the file \JBuilder\lib\jbcl.zip in the Select A JAR Or ZIP File box.

  5. Select borland.sql.monitor in the Packages Found In Archive list.

  6. Select borland.sql.monitor.MonitorButton in the JavaBeans Found In Package list.

  7. Click the Install button to add this component to the palette.

You could instead edit the file \JBuilder\bin\palette.ini. Add the following line to the section [Palette_Page3] (the Data Express page):

lib\jbcl.zip,borland.sql.monitor.MonitorButton=*

Using the MonitorButton Class from code

When the MonitorButton is added to the palette, it can be dropped on to your application. You could also add an instance of the MonitorButton in code, as follows:
	MonitorButton monitorButton1 = new borland.sql.monitor.MonitorButton();
	this.add(monitorButton1);

Understanding MonitorButton properties

The following component properties are available on MonitorButton to control the default state of the monitor:

Property Effect
MonitorURLIf this value is specified, the monitor will start up operating against a specific driver type or alias. The allowed values are:
  • jdbc:BorlandBridge: -all local aliases
  • jdbc:BorlandBridge:alias -a single local alias
  • jdbc:BorlandBroker://server -all aliases from a remote server
  • jdbc:BorlandBroker://server/alias -a single remote alias
  • jdbc: -non-DataGateway connections
EnableDriver Boolean to initialize Driver trace on/off
EnableConnection Boolean to initialize Connection trace on/off
EnableResultSet Boolean to initialize ResultSet trace on/off
EnableStatement Boolean to initialize Statement trace on/off
EnableFetch Boolean to initialize Fetch trace on/off