AnyDAC
ContentsIndexHome
PreviousUpNext
DBMS Environment Reports

This article guides you through different AnyDAC options of DBMS environment checking and reporting. Such report kind is a must for your customer support and the developer team.

Group
Links
General

All developers and supporters know the moment a customer calls about his application not running properly. Normally, it takes several phone calls or emails to get all the necessary details about his environment. Often the customer does not even have all this information. 

In general, a DBMS application may fail due to:

  • missing DBMS client libraries;
  • incorrect version of the DBMS client and/or server;
  • incorrect connection definition setup;
  • compatibility issues like an Unicode support.

AnyDAC provides the necessary methods to report all these details:

  • Using the ADExplorer or ADAdministrator: use this tool to get the report of your persistent connection definition.
  • Using the TADConnection Design Time Editor: use the TADConnection design time editor to get the detailed report about a connection definition.
  • by Code: use Delphi code to integrate the reporting capabilities into your application.

 

Using the ADExplorer

The ADExplorer utility is the main tool to maintain the centralized persistent connection definitions. Please, read the ADExplorer reference for further details. 

To get a detailed report for your persistent connection definition, run ADExplorer. Then choose a connection definition in the tree on the left side. On the right side click on the Info page. There you will see detailed environment report. 

The report includes the sections:

  • Connection definition parameters - complete set of the connection definition parameters.
  • AnyDAC info - details of your AnyDAC build.
  • Client info - information about the DBMS client software, if it is properly installed and AnyDAC is able to load it successfully. Otherwise - a failure error message.
  • Session info - information about the DBMS server and the user session, if AnyDAC was able to open successfully the connection. Otherwise - a failure error message.

The next screen shot shows the report for a MySQL connection definition. In this case the DBMS client software was loaded and the connection was activated: 

 

 

Using the TADConnection Design Time Editor

The TADConnection component design time editor is the environment to maintain temporary connection parameters. Double click any TADConnection component at design time. The AnyDAC package will display the Connection Editor dialog. 

Click on the Info page to get a detailed report for your connection definition. You will get a detailed environment report as described above. The only difference: if a TADConnection component is not connected, than the dialog will try to establish a temporary connection to a DBMS to fetch the server data. 

The next screen shot shows the resulting report: 

 

 

by Code

The AnyDAC offers several possibilities to integrate the DBMS runtime information of your environment into your own project. 

 

Call the GetInfoReport Method

You can start the DBMS report directly by calling the TADConnection.GetInfoReport method: 

 

procedure TMainForm.Button1Click(Sender: TObject);
begin
  ADConnection1.GetInfoReport(mmInfo.Lines);
end;

 

This method is declared as: 

 

procedure GetInfoReport(AList: TStrings; AItems: TADInfoReportItems);

 

The AItems flags meaning is:

  • riConnDef - include connection definition parameters into a report.
  • riAnyDAC - include AnyDAC build info into a report.
  • riClientLog - include DBMS client loading log.
  • riClient - include a DBMS client info into a report.
  • riSessionHints - include an AnyDAC, DBMS client and server potential incompatibilities.
  • riSession - include a DBMS session info into a report.
  • riTryConnect - try to connect to a DBMS, if not already connected.
  • riKeepConnected - when method established a connection, then keep it active.
  • AList - Target string list to append the report.

 

Get the AnyDAC Build Number

If you want to display the AnyDAC build number (e.g. in the About box) than just refer to the CONST C_AD_Version in the uADStanConst unit. Example: 

 

C_AD_Version = '5.0.2 (Build 1896)';

 

Get the DBMS version

To get a DBMS client and/or server version number (e.g. to switch on or off some feature in your application), use the TADConnection component and open the connection. Then use the following code sample, showing how to access the physical metadata: 

 

procedure TMainForm.Button2Click(Sender: TObject);
var
  oMetaIntf: IADPhysConnectionMetadata;
begin
  // Get client and server versions
  oMetaIntf := ADConnection1.ConnectionMetaDataIntf;
  try
    ShowMessage(Format('Client version: %.10d; Server version: %.10d',
      [oMetaIntf.ClientVersion, oMetaIntf.ServerVersion]));
  finally
    oMetaIntf:= nil; // always release the Interface before you close the connection
  end;
end;

 

You can find many predefined DBMS version numbers in uADStanConst unit:

  • cvOracleXXX - for Oracle;
  • mvMySQLXXX - for MySQL;
  • svMSSQLXXX - for MSSQL;
  • svSQLiteXXX - for SQLite;
  • svPGSQLXXX - for PostgreSQL;
  • iv{IB|FB|YF}XXX - for Interbase / Firebird / Yaffil.

The DBMS version is represented in AnyDAC by the LongWord value, consisting of the 5 groups of digits, where each group has 2 digits. Although, the leftmost group may have one single digit. For example, mvMySQL032321 = 0323210000. It corresponds to 3.23.21.0.0. This allows direct comparison of a client or server version with a constant: 

 

if oMetaIntf.ServerVersion >= mvMySQL050000 then begin
  // execute MySQL 5.0 or higher specific SQL
end
else begin
  // execute pre-MySQL 5.0 SQL
end;

<AnyDAC>\Samples\Comp Layer\TADConnection\InfoReport

What do you think about this topic? Send feedback!