FilreDAC DLL共享数据连接
D:\Users\Public\Documents\Embarcadero\Studio\16.0\Samples\Object Pascal\Database\FireDAC\Samples\Comp Layer\TFDConnection\DLL_Sharing
FDConnection1.CliHandle
FDConnection1.SharedCliHandle := ACliHandle;
CLI handle for connection sharing.
The CliHandle property returns a DBMS Call Level Interface connection handle. This value can be assigned to another TFDCustomConnection object's SharedCliHandle property. This is useful to transfer a connection from an application into a DLL. See DLL Development.
After setting Connected to True for the DLL connection, both connections will share the same physical DBMS connection. This connection must be closed after all other connections that share the same CLI handle.
CLI handle shared with other connections.
Use SharedCliHandle to set a shared DBMS Call Level Interface connection handle returned by another connection's CliHandle property. This is useful to transfer the connection from an application into a DLL (see DLL Development).
Note: A connection cannot be shared with another process, as the sharing works only inside the same address space.
After setting Connected to True for this connection, it will use the same physical DBMS connection or session as the other connection, and it will share the same transaction state.
After setting Connected to False, this DLL connection will not release the connection resources to the DBMC client. The application connection is responsible for resources releasing. Because of that, the application connection must be closed after closing all the sharing connections.
DLL Development (FireDAC)
Go Up to Working with Connections (FireDAC)
This topic describes how to use FireDAC in the dynamic loading libraries.
Contents |
General
FireDAC may be used in a DLL as in a normal application. However, developers
must be aware of two techniques, specific to DLL development.
Connection Sharing Between an Application and a
DLL
When a connection must be transferred from an application to the DLL, the
application should not transfer the TFDCustomConnection
object, because this may lead to AV errors and other issues. This is not an
issue of FireDAC. It is due to the Delphi RTL / RTTI limitations. Note that a
connection cannot be shared with another process, because the sharing works only
inside the same address space.
To transfer a connection between an application and a DLL, the application
should transfer the TFDCustomConnection.CliHandle
property value to the DLL. Here the handle must be assigned to the TFDCustomConnection.SharedCliHandle
property.
After the TFDCustomConnection.SharedCliHandle
is assigned, the DLL connection can be activated by setting Connected to
True. Note that there is no need to set up a connection definition,
including DriverID. Then, the connection can be used as a normal database
connection. Finally, it can be closed by setting Connected to False. That
does not close the physical connection, therefore the application connection
remains active.
The application connection does not track state changes performed by the DLL.
Therefore, the DLL should preserve the same transaction state as it had before
the DLL call. It is indicated not to handle transactions in a DLL, change the
transaction isolation level and other settings in a DLL.
Also, setting SharedCliHandle does not transfer any of the option values from
an application to a DLL connection object. The DLL connection options can be set
similar to the application connection options.
For example, the DLL code:
FilreDAC DLL共享数据连接的更多相关文章
- 【C++】DLL内共享数据区在进程间共享数据(重要)
因项目需要,需要在DLL中共享数据,即DLL中某一变量只执行一次,在运行DLL中其他函数时该变量值不改变:刚开始想法理解错误,搜到了DLL进程间共享数据段,后面发现直接在DLL中定义全局变量就行,当时 ...
- DLL入门浅析(5)——使用DLL在进程间共享数据
转载自:http://www.cppblog.com/suiaiguo/archive/2009/07/21/90734.html 在Win16环境中,DLL的全局数据对每个载入它的进程来说都是相同的 ...
- #pragma data_seg() 共享数据// MyData段 // 进程 // DLL
https://www.cnblogs.com/dongsheng/p/4476157.html http://www.cnblogs.com/CBDoctor/archive/2013/01/26/ ...
- 【转】VC 利用DLL共享区间在进程间共享数据及进程间广播消息
1.http://blog.csdn.net/morewindows/article/details/6702342 在进程间共享数据有很多种方法,剪贴板,映射文件等都可以实现,这里介绍用DLL的共享 ...
- 使用DLL在进程间共享数据
0x01 DLL在进程间共享数据理论 1.可以在Dll中使用#pragma data_seg建立共享类型的数据段将需要共享的数据分离出来,放置在一个独立的数据段里,并把该段的属性设置为共享,从而实现不 ...
- #pragma data_seg 共享数据区(转)
原文地址:http://www.cnblogs.com/CBDoctor/archive/2013/01/26/2878201.html 1)#pragma data_seg()一般用于DLL中.也就 ...
- 详解 Qt 线程间共享数据(用信号槽方式)
使用共享内存.即使用一个两个线程都能够共享的变量(如全局变量),这样两个线程都能够访问和修改该变量,从而达到共享数据的目的. Qt 线程间共享数据是本文介绍的内容,多的不说,先来啃内容.Qt线程间共享 ...
- VC++共享数据段实现进程之间共享数据
当我写了一个程序,我希望当这个程序同时运行两遍的时候,两个进程之间能共享一些全局变量,怎么办呢?很简单,使用VC\VC++的共享数据段.; #pragma data_seg()//恢复到正常段继续编程 ...
- Qt学习:线程间共享数据(使用信号槽传递数据,必须提前使用qRegisterMetaType来注册参数的类型)
Qt线程间共享数据主要有两种方式: 使用共享内存.即使用一个两个线程都能够共享的变量(如全局变量),这样两个线程都能够访问和修改该变量,从而达到共享数据的目的: 使用singal/slot机制,把数据 ...
随机推荐
- Cloudify介绍
一篇关于Cloudify的介绍,可以看一下:http://timeson.iteye.com/blog/1699730
- Java [Leetcode 384]Shuffle an Array
题目描述: Shuffle a set of numbers without duplicates. Example: // Init an array with set 1, 2, and 3. i ...
- 线性回归 Linear regression(2)线性回归梯度下降中学习率的讨论
这篇博客针对的AndrewNg在公开课中未讲到的,线性回归梯度下降的学习率进行讨论,并且结合例子讨论梯度下降初值的问题. 线性回归梯度下降中的学习率 上一篇博客中我们推导了线性回归,并且用梯度下降来求 ...
- EM算法定义及推导
EM算法是一种迭代算法,传说中的上帝算法,俗人可望不可及.用以含有隐变量的概率模型参数的极大似然估计,或极大后验概率估计 EM算法定义 输入:观测变量数据X,隐变量数据Z,联合分布\(P(X,Z|\t ...
- LOJ2425 NOIP2015 运输计划 【二分+LCA+树上差分】*
LOJ2425 NOIP2015 运输计划 LINK 题意:给你一颗树,可以将任意一条边的权值变成0,然后求m条路径的长度的最小值 思路: 先二分最后的距离ans,然后我们把路程大于ans的所有路径拿 ...
- codechef Far Graphs
codechef Far Graphs https://www.codechef.com/problems/TBGRAPH 题意 : 给一个简单无向图,要求构造一个序列\(a\),长度为\(n\),极 ...
- Scrapy源码研究前戏
一.Twisted的使用 在 Twisted 中,有一种特殊的对象用于实现事件循环.这个对象叫做 reactor.可以把反应器(reactor)想象为 Twisted 程序的中枢神经.除了分发事件循环 ...
- python之json扩展
#!/usr/bin/env python # -*- coding: utf8 -*- # __Author: "Skiler Hao" # date: 2017/4/9 15: ...
- vue-router教程二(要素篇之新手入门)
注意,我们将在指南中使用es 2015代码样本.此外,所有示例都将使用VUE的完整版本来使在线模板编译成为可能.请参阅这里的更多细节. 用vue路由器创建单页应用程序是非常简单的.使用vue.js,我 ...
- vue 中import和export如何一起使用(一)
前段时间碰到一个问题,vue js中要使用import来加载第三方的js,但是后面使用exports.XXX的话会报exports is not defined.那要怎么解决呢? 首先,我们要了解ES ...