当DBXPool上的DelegateConnection用于TSQLConnection时,如果在调用TSQLConnection.Open方法时SQLServer不可用,则它将第一次超时。但是,如果您随后再次调用Open,它将无法正常工作。在我的生产服务中,它会在没有任何警告的情况下终止进程-没有引发异常,什么也没有。该过程消失了……在我创建的用于测试DBXPool的简单应用程序中,它认为TSQLConnection已连接,即使没有连接也是如此。有没有人对DBXPool遇到麻烦,因为它可以提供任何建议?谢谢!>>我使用下面的编辑#1中的代码来跟踪DBX Framework。仅在使用DBXPool时才调用以下方法:(单位DBXDelegate)procedure TDBXDelegateConnection.Open;begin if not FConnection.IsOpen then begin TDBXAccessorConnection(FConnection).Open; end;end;...调用以下方法,该方法称为是否使用DBXPool:(单位DBXCommon)procedure TDBXConnection.Open;begin // mark the state open so memory can be deallocated // even if derived open or meta query fail FOpen := true; DerivedOpen; DatabaseMetaData;end;注意评论。当发生异常(例如,错误的用户名或超时等)时,仅在不使用DBXPool时才调用以下代码。(单位DBXCommon)procedure TDBXConnection.Close;begin CloseAllCommands; RollbackAllTransactions; DerivedClose; SetTraceInfoEvent(nil); FreeAndNil(FDatabaseMetaData); FOpen := false;end;因为使用DBXPool时DelegateConnection不会被设置回FOpen,所以它将导致代码执行不应该在下次调用False时执行,这会导致AccessViolation和内存损坏。有时RTL捕获了它,有时却没有捕获到它(例如,我的生产服务被Windows杀死)。我还无法更深入地了解DBXDelegate,以确定为什么它没有捕获异常并调用DerivedOpen。>>根据Ken的建议,我附上了简单的示例应用程序。我的服务应用程序快死了。该应用程序在dbxmss.dll中显示了访问冲突(今天)。昨天它没有在第二次点击时引发异常,它只是将“ Connected”返回为True。对我来说似乎是内存损坏...在带有或不带SQLServer的计算机上生成并运行该应用程序。单击每个按钮几次。两者都在第一次点击时返回错误。 “使用DBXPool”会认为从第二次单击开始就已连接。如果幸运的话,您可能会看到AV。每次“ W / O DBXPool”按钮都会失败,这是正确的。项目1.dprprogram Project1;uses Forms, Unit1 in 'Unit1.pas' {Form1};{$R *.res}begin Application.Initialize; Application.MainFormOnTaskbar := True; Application.CreateForm(TForm1, Form1); Application.Run;end.Unit1.dfmobject Form1: TForm1 Left = 0 Top = 0 Caption = 'Form1' ClientHeight = 301 ClientWidth = 562 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 object Button1: TButton Left = 40 Top = 8 Width = 75 Height = 25 Caption = 'With DBXPool' TabOrder = 0 OnClick = Button1Click end object Button2: TButton Left = 40 Top = 39 Width = 75 Height = 25 Caption = 'W/O DBXPool' TabOrder = 1 OnClick = Button2Click end object SQLConnection1: TSQLConnection DriverName = 'MSSQL' GetDriverFunc = 'getSQLDriverMSSQL' LibraryName = 'dbxmss.dll' LoginPrompt = False Params.Strings = ( 'DriverUnit=DBXMSSQL' 'DriverPackageLoader=TDBXDynalinkDriverLoader,DBXCommonDriver150.' + 'bpl' 'DriverAssemblyLoader=Borland.Data.TDBXDynalinkDriverLoader,Borla' + 'nd.Data.DbxCommonDriver,Version=15.0.0.0,Culture=neutral,PublicK' + 'eyToken=91d62ebb5b0d1b1b' 'MetaDataPackageLoader=TDBXMsSqlMetaDataCommandFactory,DbxMSSQLDr' + 'iver150.bpl' 'MetaDataAssemblyLoader=Borland.Data.TDBXMsSqlMetaDataCommandFact' + 'ory,Borland.Data.DbxMSSQLDriver,Version=15.0.0.0,Culture=neutral' + ',PublicKeyToken=91d62ebb5b0d1b1b' 'GetDriverFunc=getSQLDriverMSSQL' 'LibraryName=dbxmss.dll' 'VendorLib=sqlncli10.dll' 'MaxBlobSize=-1' 'OSAuthentication=False' 'PrepareSQL=True' 'ErrorResourceFile=' 'drivername=MSSQL' 'schemaoverride=%.dbo' 'HostName=127.0.0.1' 'Database=database' 'User_Name=username' 'Password=password' 'blobsize=-1' 'localecode=0000' 'isolationlevel=ReadCommitted' 'os authentication=False' 'prepare sql=False' 'DelegateConnection=DBXPool' 'DBXPool.MaxConnections=20' 'DBXPool.MinConnections=1' 'DBXPool.ConnectTimeout=1000' 'DBXPool.DriverUnit=DBXPool' 'DBXPool.DelegateDriver=True' 'DBXPool.DBXPool.MaxConnections=20' 'DBXPool.DBXPool.MinConnections=1' 'DBXPool.DBXPool.ConnectTimeout=1000' 'DBXPool.DBXPool.DriverUnit=DBXPool' 'DBXPool.DBXPool.DelegateDriver=True' 'DBXPool.DBXPool.DriverName=DBXPool' 'DBXPool.DriverName=DBXPool') VendorLib = 'sqlncli10.dll' Left = 8 Top = 8 end object SQLConnection2: TSQLConnection DriverName = 'MSSQL' GetDriverFunc = 'getSQLDriverMSSQL' LibraryName = 'dbxmss.dll' LoginPrompt = False Params.Strings = ( 'DriverUnit=DBXMSSQL' 'DriverPackageLoader=TDBXDynalinkDriverLoader,DBXCommonDriver150.' + 'bpl' 'DriverAssemblyLoader=Borland.Data.TDBXDynalinkDriverLoader,Borla' + 'nd.Data.DbxCommonDriver,Version=15.0.0.0,Culture=neutral,PublicK' + 'eyToken=91d62ebb5b0d1b1b' 'MetaDataPackageLoader=TDBXMsSqlMetaDataCommandFactory,DbxMSSQLDr' + 'iver150.bpl' 'MetaDataAssemblyLoader=Borland.Data.TDBXMsSqlMetaDataCommandFact' + 'ory,Borland.Data.DbxMSSQLDriver,Version=15.0.0.0,Culture=neutral' + ',PublicKeyToken=91d62ebb5b0d1b1b' 'GetDriverFunc=getSQLDriverMSSQL' 'LibraryName=dbxmss.dll' 'VendorLib=sqlncli10.dll' 'MaxBlobSize=-1' 'OSAuthentication=False' 'PrepareSQL=True' 'ErrorResourceFile=' 'drivername=MSSQL' 'schemaoverride=%.dbo' 'HostName=127.0.0.1' 'Database=database' 'User_Name=username' 'Password=password' 'blobsize=-1' 'localecode=0000' 'isolationlevel=ReadCommitted' 'os authentication=False' 'prepare sql=False') VendorLib = 'sqlncli10.dll' Left = 8 Top = 39 endend单位1unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DBXMSSQL, StdCtrls, DB, SqlExpr, DBXPool;type TForm1 = class(TForm) Button1: TButton; SQLConnection1: TSQLConnection; SQLConnection2: TSQLConnection; Button2: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementationuses DBXCommon;{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);begin SQLConnection1.Close; SQLConnection1.Open; if SQLConnection1.Connected then MessageDlg('connected connection 1', mtInformation, [mbOK], 0);end;procedure TForm1.Button2Click(Sender: TObject);begin SQLConnection2.Close; SQLConnection2.Open; if SQLConnection2.Connected then MessageDlg('connected connection 2', mtInformation, [mbOK], 0);end;procedure TForm1.FormCreate(Sender: TObject);begin // for testing purposes, shorten the timeout so that the timeout occurs quickly SQLConnection1.Params.Values[TDBXPropertyNames.ConnectTimeout] := '1'; SQLConnection2.Params.Values[TDBXPropertyNames.ConnectTimeout] := '1';end;end. (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 Embarcadero支持今天通知我,此问题已得到修复,将在下一个常规发行版(例如XE2)中提供。 (adsbygoogle = window.adsbygoogle || []).push({}); 08-28 17:31