Delphi XE (2011) + 7 + PostgreSQL 9.0 ZeosLib
Today I installed the newly releasedEmbarcadero RAD Studio XE and I liked what it found. We also intend towrite some notes about this release in the coming days.
Some time ago I wrote a little step-by-step how to install the componentpackage in Delphi 2010 ZeosLib ( http://flovato.blogspot.com/2009/10/zeoslib-for-delphi-2010.html )and today I return again to this issue but with a slightly different approach.
Also, a few weeks ago we had the release of version 9.0 of PostgreSQL, and Iwondered how this new version is supported by ZeosLib.
Download
The last official release, stable and affordable ZeosDBO is version 6.6.6 whichwas released on December 30, 2009 and supports Delphi 5 to Delphi 2007 (Delphi11).
Version 7.0 was already eagerly awaited by the public that used Delphi since2009 due to Unicode support, and even today, remains in development without adate for release.
In the previous article we used an alpha revision ZeosLib 7 and, as we will usethe latest revision of the testing branch for Delphi 2011(XE).
Checkout of the branch test ZeosLib ( svn: / / zeos.firmos.at / zeos /branches / testing ) to a directory.
If your client is svn command line, open the command prompt and move to thedirectory where you want to checkout and run the command: svn checkoutsvn: / / zeos.firmos.at / zeos / branches / testing.
If you have installed Tortoise SVN client or any other, the procedure is eveneasier.
In this article the directory D: \ Delphi \ Components \ ZeosDBO2011 \ willbe the venue for the checkout is used as a base path. So, if you choose adifferent path, just adjust the settings in step-by-step installation for thisnew path.
NOTE: The revision used during the writing of this article was r822.
Installing the Package
The installation procedure is quitesimple:
1. Open the Delphi IDE with administrator permissions. Althoughnot required, leave as a strong recommendation because of problems I had onother occasions.
2. In the Delphi IDE, click the "Open Project"fromthe "File" and navigate to the subdirectory "\packages \ delphi 15" from where it was made ZeosLibcheckout. There, open the project group ZeosDbo.groupproj.
NOTE: The "15" path that identifies the version ofDelphi, in this case, refers to Delphi XE. If you are using anotherversion, you must open the project group corresponding to that version.
A second tip for those who already have ZeosDBO 7 installed and want toupdate them, I recommend before starting the installation to be removed fromthe current version of the IDE and also deleted all files created in the lastbuild (. Dcp,. Dcu,. loca,. identcache,. dsk,. and map. bpl).
The latter can be found in the "build" (\packages \ delphi15 \ build). So, make sure that thisfolder contains no files.
3. Build all projects (Project menu -> BuildAll Projects);
If everything is ok, Delphi will report the occurrence of many hints andwarnings during the build of packages. Do not worry, for now we assumethat these reports do not present problems.
However you will most likely have an error message stating that they did notfind a particular file name (Example: "... [DCC Fatal Error]ZCore.dpk (51): F1026 File not found: 'ZVariant.dcu' .. .. ")
To fix this simply just find the corresponding file mentioned in the errormessage from the subdirectory "src" in the placewhere the checkout was done and add the full path in the Path libray Delphi(Menu Tools -> Options -> Environment Options -> DelphiOptions -> Library).
To avoid this andseveral other reports of this type, add each of the subdirectories for thesource code of the Library Path ZeosLib, as shown in the picture below.
Note that thedefinition of the paths I use "$ (DelphiComponents) \".
In my work there is anenvironment variable called DelphiComponents that is intendedto refer to the directory where all the components / third-party packages arelocated.
This facilitates themigration and use of different versions of components without requiringreconfiguration of the path in the projects or in the Delphi IDE.
If you have not or willnot add this environment variable, just replace "$(DelphiComponents) \" path by which the ZeosDBO is located (whichthis article is D: \ Delphi \ Components \ ZeosDBO2011).
NOTE: If after addingthe directories in the Delphi Library Path continues to display the errormessage, just close it and reopen it. Do not forget to reopen it withadministrator permissions!
4. Install the package of components by selecting the "Install" (fromthe context menu) package "ZComponentDesign150.bpl";
If you try to installthe package "ZComponentDesign150.bpl" is displayedan error message like the image below, it means that Delphi did not find thefile. GLP specific.
The most practical and quick to fix this problem is to enter the directorywhere this. BPL is located in the PATH system.
Note that when builder packages ZeosLib will be created a directory located inthe subdirectory called build. "\ Packages \ delphi15."
So, just add this path (D: \ Delphi \ Components \ ZeosDBO2011 \ packages \delphi15 \ build) in the directory listing of the environment variable "PATH".
NOTE: Any changes in the environment variables will require close and reopenthe Delphi for the changes to take effect.
If you try to install the package "ZComponentDesign150.bpl" isdisplayed an error message same as or similar to the image below, was probablyan oversight in the specification of the path ZeosDBO.
Classify as careless because this error was caused when he was trying toinstall ZeosDBO who was in a path different from that referenced in the SystemPath and Library Path (in the Delphi IDE).
So, be sure to indicate exactly all the path to the directory where the ZeosDBis located.
If all goes well Delphi will present a dialog informing the list of componentsthat were installed.
5. Validating the installation package
Optionally, you can actually confirm that the installation is consistent bychecking the installed component packages in Delphi.
To access this menu Component -> Install Packages... and find the entry "Zeos Database Components".
Connection to PostgreSQL 9.0
The first question to be seen is whether this version of ZeosDBO can at leastconnect to PostgreSQL.
At this point it is assumed that you have already installed PostgreSQL 9.0.
For this basic test, anew project was created and a componentTZConnection was dropped onthe form.
Note on the image thatthe connection was made successfully on the database itself postgres(metadata).
A point to note is thatthe list of protocols (protocol property) there is an item "postgresql-9" asexpected. Thus, the most likely option was to use "postgresql-8."
I think the time isadded with an exclusive option for postgresql version 9, since this introducessignificant changes.
The component configuration TZConnection the DFM is presented as:
ZConnection1 object: TZConnection
Properties.Strings = (
'Codepage = UTF8'
'Client_encoding = UTF8')
AutoCommit = False
Connected = True
Protocol = 'postgresql-8'
HostName = '127 .0.0.1 '
Port = 5432
Database = 'postgres'
User = 'postgres'
Password = 'mypassword'
Left = 126
Top = 16
end
After changing the component and set the Connected property to True forthe first time, a notification error like the image below was presented.
This is a classicproblem that is solved or by copying the necessary files to the project folderor by adding the directory where those files are located in the PATH system.
All DLLs are located inthe subdirectory "bin" of the PostgreSQLinstallation directory (probably C: \ Program Files \ PostgreSQL \ 9.0\ bin).
As shown in the picture above, the chosen solution was to add the PostgreSQLinstallation directory to the PATH system that is not necessary to have torecopy the DLLs for new projects that use the ZeosDBO.
After this was only necessary to close and reopen the Delphi and the connectionwas as expected.
Performing queries
After a successful connection, I performed some tests with the basic componentsto display the records of the tables.
In the picture below you can notice the DBGrid component displaying informationin the table "INFORMATION_SCHEMA.TABLES."
Despite a few basic tests done in design mode, the components apparently areworking well. I did not notice any kind of failure.
To validate likely to support issues that are often observed in specificcircumstances or after a long time of use, I decided to migrate an entiresystem developed in Delphi 2010 to Delphi XE.
This system has a database framework based on ZeosDBO and, in theory, build andrun this system through the Delphi XE would expose any lack of support for thePostgreSQL 9.0, since this framework makes moderate use of resources /components ZeosDBO and the system has a relatively large database.
Migrating the system to Delphi XE
I figured it would be more work, but hardly had to do much.
When you open the project group in this system that was created in Delphi 2010,Delphi XE not even make any kind of format conversion.
The only job I had was replacing, in clause of the projects require thereporting of some third party component packages (eg by replacing tms2010tms2011). This does not cost more than 30 minutes.
I only found problems with some third party packages that were beingused.However, for all had a newer version that supported the Delphi XE. Thus,the real work was to install new versions of these packages, except for onethat required some manual intervention.
Well, here's what interests us is the support for PostgreSQL 9.0 and ZeosDBOabout it surprisingly was not necessary to modify a line if you want thedatabase framework (the framework was created in 2008 with the still-newversion 6.6.4 the ZeosDBO!). The build system was 100% without any problem(only a few hints).
The focus of this post is not migrating to Delphi XE systems, but theexperience was very positive. And I encourage anyone using Delphi 2010 tomake this upgrade.
Initially I thought that was too good to be true and everyone would simply turnthe system upside for the colors appear. To my delight, the softwareusually performed successfully passing all tests automated.
Conclusion
I am fully aware that it is a broader use of components and features ofthis framework ZeosDBO database, it is rash to conclude that the alpha releaseof version 7.0 is fully compatible with PostgreSQL 9.0, but I feel tranquilencourage anyone who is thinking about doing some kind of migration / upgradeseemed to do so.
|