如何使用FireDAC在Firebird 3.0上启用WireCompression

时间:2016-11-30 09:04:26

标签: delphi compression firebird firedac firebird-3.0

我希望使用WireCompression连接到Firebird Server 3.0。这是3.0版以来的新功能,我很难做到这一点,我能找到的唯一记录的指令是在firebird.conf中将WireCompression设置为TRUE并使用connect参数“wirecompression = true”。

这就是我迄今为止所拥有的:

firebird.conf:

# Firebird configuration file for Firebird 3.0 64-bit SuperServer
# Optimized by IBSurgeon (www.ib-aid.com) for HQbird distribution.
#

ServerMode = Super

#DatabaseAccess = Full
#RemoteAccess = true
#ExternalFileAccess = None
#UdfAccess = Restrict UDF
#TempDirectories =
#AuditTraceConfigFile =
#MaxUserTraceLogSize = 10

DefaultDbCachePages = 50000

#DatabaseGrowthIncrement = 128M
#FileSystemCacheThreshold = 64K
#FileSystemCacheSize = 0
#RemoteFileOpenAbility = 0

TempBlockSize = 2M
TempCacheLimit = 364M

AuthServer = Srp
AuthClient = Srp, Win_Sspi, Legacy_Auth
UserManager = Srp
#WireCryptPlugin = Arc4

#hqbird traceapi plugin should be in plugins folder!
TracePlugin = fbtrace2db

#CryptPlugin = Arc4
#KeyHolderPlugin =
#Providers = Remote,Engine12,Loopback
#DeadlockTimeout = 10
#MaxUnflushedWrites = 100
#MaxUnflushedWriteTime = 5
#BugcheckAbort = 0
#RelaxedAliasChecking = 0
#ConnectionTimeout = 180
#(for client) / Required (for server)

WireCompression = true
WireCrypt = enabled
#DummyPacketInterval = 0
#RemoteServiceName = gds_db

RemoteServicePort = 3050

#RemoteAuxPort = 0
#TcpRemoteBufferSize = 8192
#TcpNoNagle = 1
#RemoteBindAddress =

LockMemSize = 9M

#LockAcquireSpins = 0

LockHashSlots = 30011

#EventMemSize = 64K
#CpuAffinityMask = 0
#GCPolicy = combined
#SecurityDatabase = $(dir_secDb)/security3.fdb

GuardianOption = 1

#ProcessPriorityLevel = 0
#IpcName = FIREBIRD
#RemotePipeName = interbas

连接代码:

  //Info: FDB = TFDConnection
  with FDB.Params do
  begin
      Clear;
      Add('DriverID=FB');
      Add('Database=' + vDatabase);
      Add('User_Name=' + AUsername);
      Add('PassWord=' + APassword);
      Add('WireCompression=true');
  end;

  FDB.FetchOptions.Unidirectional:= true;
  FDB.FetchOptions.RowsetSize:= 1000;
  FDB.ResourceOptions.SilentMode:= true;

  FDB.Connected := true;

  vConnectionInfo:= TStringList.Create;
  FDB.GetInfoReport(vConnectionInfo);

  ShowMessage(vConnectionInfo.Text);

  Clipboard.AsText:= vConnectionInfo.Text;

  FreeAndNil(vConnectionInfo);

  Result := FDB.Connected;

建立连接,但vConnectionInfo说:

================================
Connection definition parameters
================================
DriverID=FB
Database=server:D:\Databases\FB3.0\test\test.FDB
User_Name=sysdba
PassWord=*****
WireCompression=true
================================
FireDAC info
================================
Tool = RAD Studio 10.1 Berlin
FireDAC = 15.0.1 (Build 86746)
Platform = Windows 32 bit
Defines = FireDAC_NOLOCALE_META;FireDAC_MONITOR
================================
Client info
================================
Loading driver FB ...
Brand = Firebird
Client version = 300009900
Client DLL name = D:\D10\Projects\TestFB30 Client\Win32\Debug\fbclient.dll
================================
Session info
================================
Current catalog = 
Current schema = 
Server version = WI-V3.0.0.32483 Firebird 3.0
WI-V3.0.0.32483 Firebird 3.0/tcp (server)/P13:C
WI-V3.0.0.32483 Firebird 3.0/tcp (laptop)/P13:C

最后两行说我有协议v13(P13),数据是enCrypted(:C),但应该是P13:CZ表示zlib压缩。

我在客户端的调试文件夹中有zlib1.dll,并且Firebird服务器文件夹中的服务器上存在zlib1.dll。

可以连接到数据库,我收到没有错误消息。

我已经没有足够的想法来应用压缩,但我相信你们可以帮助我!

1 个答案:

答案 0 :(得分:4)

为了使用FireDAC启用zlib压缩,您只需要:

  1. 通过设置wirecompression = true
  2. ,使用firebird.conf启用wirecompression服务器端
  3. 拥有正确/相同版本的fbclient.dll客户端
  4. 将正确的zlib1.dll(在我的情况下为x86)放在包含客户端exe的文件夹中
  5. 创建一个firebird.conf并添加line wirecompression = true并将其保存到exe所在的文件夹中。
  6. 将wirecompression = true添加到连接参数
  7. 现在启用了Wirecompression。