dbExpress Feature Overview
Go Up to Developing Database Applications for the Win32 Platform Index
The dbExpress top-level framework and metadata support now offers new, richer metadata support. The DbxClient driver remotes the dbExpress 4 framework interface over a network-based transport.
This document discusses the following features:
- dbExpress Framework
- dbExpress Metadata Improvements
- DBXClient Driver
- DBXDynalink Driver
- DBTest
Contents
dbExpress Framework
VCL
The dbExpress VCL component's implementation has changed with minimal change to the API. Most applications are not affected by changes to the dbExpress VCL. However, there are some new methods, properties, events, constants, and enums.
dbExpress Metadata Improvements
New metadata providers for 9 different database backends are written completely in Delphi. Full source code to all metadata providers is included in the product.
Metadata read and write capabilities
Each provider is composed of a metadata reader and metadata writer implementation contained inside the dbExpress driver packages. The separate metadata readers and writers that were in the DbxReadOnlyMetaData and DbxMetaData packages no longer exist.
Provider based approach
The metadata providers are detached from the driver, so that one metadata provider can be used for multiple driver implementations as long as the database backend is the same. Data Explorer also takes advantage of metadata providers to provide metadata support for other database drivers.
The provider is not bound to a driver, but to a database back end. There is a new property called TDBXPropertyNames.MetaDataPackageLoader in the dbxdrivers.ini files that can be set to a TDBXCommandFactory object. This command factory implementation creates a TDBXCommand that can execute metadata commands. This approach allows multiple driver implementations for a specific database backend to use the same metadata provider. Data Explorer also takes advantage of this architecture to provide dbExpress 4 structured metadata for drivers from other vendors. The decoupling of driver and metadata provider also benefits "thin" driver implementations. If metadata commands can be serviced on a server, there is no need to have the metadata provider logic on the client.
Provider source directory
All database source is now contained in the following installation location:
C:\Program Files (x86)\Embarcadero\Studio\23.0\source\database
Reading metadata
The unit DBXMetaDataNames has been provided to read metadata. The dbExpress class TDBXMetaDataCommands provides a set of constants to read various types of metadata. Set the Data.DBXCommon.TDBXCommand.CommandType property to Data.DBXCommon.TDBXCommandTypes.DBXMetadata and set Data.DBXCommon.TDBXCommand.Text to one of the constants in TDBXMetaDataCommands to acquire the designated metadata. Data.DBXCommon.TDBXCommand.ExecuteQuery returns a Data.DBXCommon.TDBXReader to access the metadata. The new classes in DBXMetaDataNames describe and provide access to this metadata's columns.
Writing metadata
Support for creating SQL dialect sensitive CREATE, ALTER, and DROP statements is provided in Data Explorer. dbExpress also exposes a DbxMetaDataProvider class that surfaces this capability for applications. This slightly increases the size of application, since the metadata writers must be included. The ability to generically create tables is useful for many applications. The interface allows you to describe what a table and its columns look like and pass this description to the TdbxMetaDataProvider.CreateTable method. Here is a simple example that shows how to create a table with an int32 column named "C1", a decimal with a precision of 10 and scale of 2 named "C2", and a character based column with a precision of 32 named "C3".
var MetaDataTable: TDBXMetaDataTable; DataGenerator: TDbxDataGenerator; Command: TDBXCommand; Row: Integer; begin MetaDataTable := TDBXMetaDataTable.Create; MetaDataTable.TableName := 'QCXXX_TABLE'; MetaDataTable.AddColumn(TDBXInt32Column.Create('C1')); MetaDataTable.AddColumn(TDBXDecimalColumn.Create('C2', 10, 2)); MetaDataTable.AddColumn(TDBXUnicodeCharColumn.Create('C3', 32)); MetaDataProvider.CreateTable(MetaDataTable); end
Deployment
For information about deploying database applications, see Deploying Database Applications.
Compatibility
The VCL components in the SqlExpr unit still work with drivers that provide the more limited dbExpress 3 metadata. However, Data Explorer only works with dbExpress 4 metadata.
Note that Delphi includes metadata for 9 different database backends. Thus any dbExpress driver implementation for the 9 backends supported can reuse the metadata provider with their driver implementation.
DBXClient Driver
DBXClient is a thin dbExpress 4 driver that remotes the dbExpress 4 framework interface over a pluggable network based transport. In this release, a TCP/IP transport is supported. The driver uses a JSON/RPC (Java Script Object Notation) based streaming protocol.
The DBXClient is implemented in 100% Delphi. Its source code is included in the product.
Connectivity
DBXClient can connect to DataSnap. DataSnap provides a middle-tier application server that contains and manages remote data modules. DataSnap has been enhanced to provide a very general connection mechanism between components in different tiers.
To use the DBXClient driver with DataSnap, add the DBXClient unit to the uses clause.
Deployment
DBXClient needs no database client library installed when you deploy your application. DBXClient is 100% Delphi and can be directly linked into your application as a single .exe file.
For further information about deploying database applications, see Deploying Database Applications.
DBTest
This is a collection of classes that extend the capabilities of Dunit to facilitate database testing. The qcreport and cts sample Dunit tests provide good examples of how to make use of DBTest. TestCaseExtension contains non-database related extensions to Dunit and the DBXTest unit contains database related extensions.
Command line properties
New units have been added to the DbxDynalinkDriver package for all 8 of Dynalink drivers:
Test selection
-s:<TestName> command line can be used to execute just a single method in a Dunit test case. This is useful for debugging a single bug. See the TestCaseExtension unit.
Convenience methods
There are several methods for creating default connection and metadata provider. See the DBXTest unit.
Data generator
There is a simple, extensible data generator. See the DBXDataGenerator unit.