The method of UNIDAC wire break re-connection

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.