Software Development Kit
to the Delphi-Win32 and Free Pascal compilers
Home > Wiki > PhonebookProject/Article3

PhonebookProject/Article3

english (en) | português (pt)



This article will present the creation of the database and configuring the connector to access data.

Contents

Creation of database

Create a new database to store the objects of the project. Then run the application, press Shift + Alt + 9 to copy the database's metadata to the clipboard. Adapt the script to the preferences of collation and character set of columns and run it on the database front-end.

Record the final script in the folder {phonebook}\Source\Metadata\Firebird\firebird.sql or in the folder of the database used. This script is useful to run a diff and create a script to change the metadata of the database in future articles.

Connector Configuration

Create the file {phonebook}\Source\Core\Projects\D5\PhoneBook.cf (ie, ProjectName.cf in the same folder as executable) with the following contents:

[OPFBroker]
DefaultServiceName := 'UIB';

[OPFBroker.UIB]
Connector.Database.CharacterSet := csISO8859_1;
Connector.Database.LibraryName := 'fbclient.dll';
Connector.Database.DatabaseName := 'localhost:c:\data\PhoneBook.fb';
Connector.Database.UserName := 'SYSDBA';
Connector.Database.PassWord := 'masterkey';

The above example uses UIB to connect to a Firebird database.

Using another connector

To use another connector:

  • Assign a new name on the DefaultServiceName connector property
  • Change the name of the sub-session OPFBroker.UIB to OPFBroker.ConnectorName
  • Change the sub-session OPFBroker.ConcectorName according to connection properties

The properties of this sub-session are all public properties (published) in OPFBroker service class. If these properties are a class, all published properties of that class are also available as a path:

ServiceProp.OutherClasseProp.ValueProp := 'value';

To know these properties, check the class declaration unit of their broker. For the UIB connector, the service is stated in the unit {press}\Source\Brokers\PressUIBBroker.pas.

Finalizing and testing the application

The configuration of the database and the connector is the last step of building the application. The only PressObjects dependence, to the deployment of the application is the configuration file (PhoneBook.cf). Put him with the other dependencies, as the client library database and library of the connection (if any).

New articles will deal with application improvements, such as: events, grid personalization, access control, reports at runtime, the dababase's encrypted password, among others.