Connection Tracing (Delegate Drivers tutorial)

From RAD Studio
Jump to: navigation, search

Go Up to Tutorial:_Using_dbExpress_Delegate_Drivers

To be able to trace the connection activity, you must set the DelegateConnection parameter of the connection.

DBXTrace ObjectInspector.PNG

There are several ways to do this:

  • Edit the properties of the TSQLConnection component using the Object Inspector.
  • Modify the connection using the Data Explorer pane.
  • Add the DelegateConnection=DBXTraceConnection line to the [DGCONNECTION] section in the dbxconnections.ini file.

Tip: If you want to trace and pool a connection by modifying the dbxconnections.ini file, you will find it in C:\Users\Public\Documents\Embarcadero\Studio\19.0\dbExpress\19.0.

The easiest way is to edit the properties of TSQLConnection using the Object Inspector.

In the previous step, the Driver property of SQLConnection1 TSQLConnection was automatically set to Interbase when the ConnectionName property was set to DGCONNECTION.

Now go to the DelegateConnection property and set it to DBXTrace, using the property's drop-down menu. You will see that DelegateName is automatically set to DBXTrace. Set the TraceFile property to "c:\temp\dbxtrace.txt". A .txt file will be created on this location and the log will be written here.

You can enable or disable the flags of the TraceFlags property to change what is traced. To see the log statements at the driver level, you need to set the TraceDriver to True.

Tip: If you are using a console application and the TraceFile parameter is not specified, the output is shown on the console window.

Now the connection will be traced and a log file will be created according to the TraceFile parameter.

To test the connection tracing, run the application and connect to DGCONNECTION. The output file will look like this:

Log Opened ==========================================
{CONNECT        } ConnectionC1.GetConnectionProperties;
{CONNECT        } ConnectionC1.Open;
{COMMAND        } CommandC1_1 := ConnectionC1.CreateCommand;
{COMMAND        } CommandC1_1.CommandType := 'Dbx.MetaData';
{COMMAND        } CommandC1_1.Text := 'GetTables "c:\Embarcadero\InterBase\examples\database\employee.gdb"."sysdba".% Table;View;';
{COMMAND        } ReaderC1_1_1 := CommandC1_1.ExecuteQuery;
{READER         }  {CatalogName  TDBXTypes.WideString }
{READER         }  {SchemaName  TDBXTypes.WideString }
{READER         }  {TableName  TDBXTypes.WideString }
{READER         }  {TableType  TDBXTypes.WideString }
{READER         }  { ReaderC1_1_1 closed.  11 row(s) read }
{READER         } FreeAndNil(ReaderC1_1_1);
{COMMAND        } FreeAndNil(CommandC1_1);
{CONNECT        } ConnectionC1.GetConnectionProperty; 


The log file shows the actual Delphi source code that is being executed.


Next

Previous