The uniconnection of the KBM server is to implement a wire break reconnection (connection MSSQLServer), which requires the following steps:
First, modify the unit file: Kbmmwunidac.pas
Procedure Tkbmmwunidacconnection.internalopenconnection (connectionpool:tkbmmwcustomconnectionpool); Begin// Create New database connection using template. With Tkbmmwunidacconnectionpool (ConnectionPool). Fdbtemplate do begin//need to add this statement for UNIDAC, otherwise the connection database fails fdatabase.server: = Server; Fdatabase.database: = Database; Fdatabase.username: = Username; Fdatabase.password: = Password; Fdatabase.loginprompt: = False; Fdatabase.providername: = ProviderName; Fdatabase.port: = Port; FDatabase.SpecificOptions.Assign (specificoptions); Support Unidac re-linked fdatabase.options.localfailover:=options.localfailover; Fdatabase.onconnectionlost:=onconnectionlost; Fdatabase.afterconnect:=afterconnect; With Tkbmmwunidacconnectionpool (ConnectionPool) does if Assigned (fonsetupdbconnection) then fonsetupdbconnection (self,fdatabase); End If fdatabase.providername= ' SQL Server ' then CoInitialize (nil); Fdatabase.open;end;
Two. Put Uniconnection's options.localfailover:=true;
Three. The Connectionlost event in Uniconnection is modified as follows:
Procedure TDM. Con_aconnectionlost (Sender:tobject; component:tcomponent; Connlostcause:tconnlostcause; Retrymode:tretrymode var); begin //wire break re -union if (Sender as Tuniconnection). Tag<1 then begin Retrymode:=rmreconnectexecute; (Sender as Tuniconnection). Tag:= (Sender as Tuniconnection). tag+1; End Else begin Retrymode:=rmraise; (Sender as Tuniconnection). tag:=0; End;end;
Iv. If there is a call to Uniquery or other database components in a function on the server, add: CoInitialize (nil) at the beginning of the function; End add: couninitialize;
The method of UNIDAC wire break re-connection