设为首页 收藏本站
查看: 1184|回复: 0

[经验分享] ZeosLib For Delphi XE (2011)

[复制链接]

尚未签到

发表于 2016-11-22 02:52:40 | 显示全部楼层 |阅读模式
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.


DSC0000.png




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


DSC0001.png



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.


DSC0002.png




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.



DSC0003.png




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";


DSC0004.png




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.



DSC0005.png




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".


DSC0006.png




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.


DSC0007.png




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.


DSC0008.png





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".


DSC0009.png






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.


DSC00010.png



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.

DSC00011.png


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).



DSC00012.png




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."


DSC00013.png




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.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-303538-1-1.html 上篇帖子: PostgreSql8.0的安装与初始化 下篇帖子: (转) JDBC驱动下载及连接字符串URL写法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表