UniDAC使用教程(五):在不稳定的网络中工作

UniDAC数据库访问组件详解
UniDAC是一款通用数据库访问组件,支持多种平台如Windows、MacOSX、iOS、Android等,提供对Oracle、微软SQL等多种数据库的直接访问。在不稳定网络环境中,建议使用特定设置以最小化对服务器的请求,包括启用本地故障转移、断开连接模式、缓存更新等,以降低连接中断的风险。在断开连接模式下,数据集可在无活动连接的情况下工作,减少服务器资源使用。

下载UniDAC最新版本

Universal Data Access Components (UniDAC)是一款通用数据库访问组件,提供了多个数据库的直接访问,如针对Windows的Delphi, C++Builder, Lazarus (以及 Free Pascal) , Mac OS X, iOS, Android, Linux和64和32位的FreeBSD等等。我们将长期的经验集于这个小组件,提供统一的数据库连接访问(如oracle、微软SQL等等)。这意味着您可以在您的项目之间轻松地切换不同的数据库,以及创建跨数据库应用程序接口。

建议在不稳定网络中工作时使用以下设置:

1

2

3

4

5

6

TCustomDAConnection.Options.LocalFailover = True

TCustomDAConnection.Options.DisconnectedMode = True

TDataSet.CachedUpdates = True

TCustomDADataSet.FetchAll = True

TCustomDADataSet.Options.LocalMasterDetail = True

AutoCommit = True

这些设置最小化了对服务器的请求数。使用TCustomDAConnection.Options.DisconnectedMode可以使数据集在没有活动连接的情况下工作。它最大限度地减少了服务器资源的使用,并降低了连接中断的可能性。也就是说,在这种模式下,如果不再需要连接,连接将自动关闭。但是每个显式操作都必须显式完成。这意味着每个显式连接后面都必须是显式断开连接。

将FetchAll属性设置为True允许在光标打开后获取所有数据并关闭连接。如果您使用的是主/细节关系,建议将LocalMasterDetail选项设置为True。

不建议显式准备查询。使用CachedUpdates模式编辑数据集数据。使用TCustomDADataSet.Options.UpdateBatchSize属性减少对服务器的请求数。

如果连接中断,则会发生致命错误,如果满足以下条件,则会引发OnConnectionLost事件:

  • 没有活动的事务;
  • 没有打开和未获取的数据集;
  • 没有显式准备的数据集或SQL。

如果用户不拒绝建议的retryMode参数值(或不使用OnConnectionLost事件处理程序),则UniDAC可以隐式执行以下操作:

1

2

3

Connect;

DataSet.ApplyUpdates;

DataSet.Open;

即当连接中断时,执行隐式重新连接,并重新执行相应的操作。我们建议在事务中包装其他操作,并自己完成它们的重新执行。

由于连接持续时间缩短,在Disconnected模式下使用池可以加快大多数操作。

转载于:https://my.oschina.net/u/4009527/blog/3009057

Universal Data Access Components(UniDAC) 是一个功能强大的支持多数据库的引擎,可以安装在Delphi, Delphi for .NET, C++Builder。UniDAC 的目的是帮助程序员更快的开发数据库应用软件。 UniDAC是一个完整的标准数据库连接解决方案,可以支持 Oracle, SQL Server, MySQL, InterBase, 和 Firebird。 本版本支持以下 IDE: Lazarus1 Delphi 6,7,2005 C++Builder 6 BDS 2006 (Delphi 2006, C++Builder 2006) RAD Studio 2007 (Delphi 2007, C++Builder 2007) RAD Studio 2009 (Delphi 2009, C++Builder 2009) RAD Studio 2010 (Delphi 2010, C++Builder 2010) 可以点击\Source\Delphi14\make.bat安装 3.00.0.3 13-Oct-09 Now setting the SetFieldsReadOnly option to False makes all fields not readonly Now the AssignConnect method copies transaction state Fixed bug with locating records using the LocateEx method and the lxNearest option Fixed bug with AV failure in MemData Fixed bug with SQL Generator in design-time Fixed problem with help registration under RAD Studio 2010 Fixed problem with loading DataSet Manager under RAD Studio 2010 Fixed problem with providers registration under RAD Studio 2010 Added support for GUID data type in the ODBC-based providers Added support for autoincrement fields in the Access, Advantage, and DB2 providers Added the ServerTypes specific option for the Advantage provider Added support for *.accdb databases in the Access provider Fixed error on connect under Windows Vista / 7 in the Access provider 3.00.0.2 10-Sep-09 Embarcadero RAD Studio 2010 suppored DB2, Microsoft Access, Advantage Database Server, Adaptive Server Enterprise, and other databases (using ODBC provider) support added Now the subdetail is refreshed before the AfterRefresh event of the detail is called ConnectionTimeout is now used when resolving the host name --------------------------- 该资源是从盒子载到的,点了好几次才载到,所以蛮传一个,方便点。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值