您的位置:首页 > 编程语言 > Delphi

ZeosLib For Delphi XE (2011)

2011-09-10 01:16 609 查看
Delphi XE (2011) + 7 + PostgreSQL 9.0 ZeosLib

Today I installed the newly released
Embarcadero RAD Studio XE and I liked what it found. We also intend to
write some notes about this release in the coming days.

Some time ago I wrote a little step-by-step how to install the component
package 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 I
wondered how this new version is supported by ZeosLib.

Download

The last official release, stable and affordable ZeosDBO is version 6.6.6 which
was released on December 30, 2009 and supports Delphi 5 to Delphi 2007 (Delphi
11).

Version 7.0 was already eagerly awaited by the public that used Delphi since
2009 due to Unicode support, and even today, remains in development without a
date for release.

In the previous article we used an alpha revision ZeosLib 7 and, as we will use
the 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 the
directory where you want to checkout and run the command: svn checkout
svn: / / zeos.firmos.at / zeos / branches / testing.


If you have installed Tortoise SVN client or any other, the procedure is even
easier.



In this article the directory D: \ Delphi \ Components \ ZeosDBO2011 \ will
be the venue for the checkout is used as a base path. So, if you choose a
different path, just adjust the settings in step-by-step installation for this
new path.

NOTE: The revision used during the writing of this article was r822.

Installing the Package



The installation procedure is quite
simple:

1. Open the Delphi IDE with administrator permissions. Although
not required, leave as a strong recommendation because of problems I had on
other occasions.

2. In the Delphi IDE, click the "Open Project"from
the "File" and navigate to the subdirectory "\
packages \ delphi 15" from where it was made ​​ZeosLib
checkout. There, open the project group ZeosDbo.groupproj.

NOTE: The "15" path that identifies the version of
Delphi, in this case, refers to Delphi XE. If you are using another
version, you must open the project group corresponding to that version.

A second tip for those who already have ZeosDBO 7 installed and want to
update them, I recommend before starting the installation to be removed from
the current version of the IDE and also deleted all files created in the last
build (. Dcp,. Dcu,. loca,. identcache,. dsk,. and map. bpl).

The latter can be found in the "build" (\
packages \ delphi15 \ build).
So, make sure that this
folder contains no files.

3. Build all projects (Project menu -> Build
All Projects);


If everything is ok, Delphi will report the occurrence of many hints and
warnings during the build of packages. Do not worry, for now we assume
that these reports do not present problems.



However you will most likely have an error message stating that they did not
find 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 error
message from the subdirectory "src" in the place
where the checkout was done and add the full path in the Path libray Delphi
(Menu Tools -> Options -> Environment Options -> Delphi
Options -> Library).


To avoid this and
several other reports of this type, add each of the subdirectories for the
source code of the Library Path ZeosLib, as shown in the picture below.



Note that the
definition of the paths I use "$ (DelphiComponents) \".

In my work there is an
environment variable called DelphiComponents that is intended
to refer to the directory where all the components / third-party packages are
located.

This facilitates the
migration and use of different versions of components without requiring
reconfiguration of the path in the projects or in the Delphi IDE.

If you have not or will
not add this environment variable, just replace "$
(DelphiComponents) \"
path by which the ZeosDBO is located (which
this article is D: \ Delphi \ Components \ ZeosDBO2011).

NOTE: If after adding
the directories in the Delphi Library Path continues to display the error
message, just close it and reopen it. Do not forget to reopen it with
administrator permissions!

4. Install the package of components by selecting the "Install" (from
the context menu) package "ZComponentDesign150.bpl";



If you try to install
the package "ZComponentDesign150.bpl" is displayed
an error message like the image below, it means that Delphi did not find the
file. GLP specific.



The most practical and quick to fix this problem is to enter the directory
where this. BPL is located in the PATH system.

Note that when builder packages ZeosLib will be created a directory located in
the 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 reopen
the Delphi for the changes to take effect.

If you try to install the package "ZComponentDesign150.bpl" is
displayed an error message same as or similar to the image below, was probably
an oversight in the specification of the path ZeosDBO.



Classify as careless because this error was caused when he was trying to
install ZeosDBO who was in a path different from that referenced in the System
Path and Library Path (in the Delphi IDE).

So, be sure to indicate exactly all the path to the directory where the ZeosDB
is located.

If all goes well Delphi will present a dialog informing the list of components
that were installed.



5. Validating the installation package

Optionally, you can actually confirm that the installation is consistent by
checking 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 least
connect to PostgreSQL.

At this point it is assumed that you have already installed PostgreSQL 9.0.



For this basic test, a
new project was created and a componentTZConnection was dropped on
the form.

Note on the image that
the connection was made successfully on the database itself postgres
(metadata).

A point to note is that
the list of protocols (protocol property) there is an item "postgresql-9" as
expected. Thus, the most likely option was to use "postgresql-8."

I think the time is
added with an exclusive option for postgresql version 9, since this introduces
significant 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 for
the first time, a notification error like the image below was presented.



This is a classic
problem that is solved or by copying the necessary files to the project folder
or by adding the directory where those files are located in the PATH system.

All DLLs are located in
the subdirectory "bin" of the PostgreSQL
installation directory (probably C: \ Program Files \ PostgreSQL \ 9.0
\ bin).




As shown in the picture above, the chosen solution was to add the PostgreSQL
installation directory to the PATH system that is not necessary to have to
recopy the DLLs for new projects that use the ZeosDBO.

After this was only necessary to close and reopen the Delphi and the connection
was as expected.

Performing queries

After a successful connection, I performed some tests with the basic components
to display the records of the tables.

In the picture below you can notice the DBGrid component displaying information
in the table "INFORMATION_SCHEMA.TABLES."



Despite a few basic tests done in design mode, the components apparently are
working well. I did not notice any kind of failure.

To validate likely to support issues that are often observed in specific
circumstances or after a long time of use, I decided to migrate an entire
system developed in Delphi 2010 to Delphi XE.

This system has a database framework based on ZeosDBO and, in theory, build and
run this system through the Delphi XE would expose any lack of support for the
PostgreSQL 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 the
reporting of some third party component packages (eg by replacing tms2010
tms2011).
This does not cost more than 30 minutes.

I only found problems with some third party packages that were being
used.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 one
that required some manual intervention.

Well, here's what interests us is the support for PostgreSQL 9.0 and ZeosDBO
about it surprisingly was not necessary to modify a line if you want the
database framework (the framework was created in 2008 with the still-new
version 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 the
experience was very positive. And I encourage anyone using Delphi 2010 to
make this upgrade.

Initially I thought that was too good to be true and everyone would simply turn
the system upside for the colors appear. To my delight, the software
usually performed successfully passing all tests automated.

Conclusion

I am fully aware that it is a broader use of components and features of
this framework ZeosDBO database, it is rash to conclude that the alpha release
of version 7.0 is fully compatible with PostgreSQL 9.0, but I feel tranquil
encourage anyone who is thinking about doing some kind of migration / upgrade
seemed to do so.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: