#1 2017-08-01 13:35:07

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

MySQL Server has gone away

Concerning to topic https://synopse.info/forum/viewtopic.php?id=4061
i made some modifications to my code and made the ConnectionProperties a Member of my ViewModel Class. so far so good (german so weit so gut smile )

Now i made a few tests with TSQLDBZEOSConnectionProperties and have encountered the following problems. (Our Main Database is a MySQL Server !)

Scenario 1

Stop MySQL
Start Service
TSQLDBZEOSConnectionProperties.Create raises Exception - Could not find server. As WorkAround i programmed a function like this

    property ConnectionProperties : TSQLDBConnectionProperties read GetConnectionProperties;

function TApplication.GetConnectionProperties: TSQLDBConnectionProperties;

  function CreateConnectionProperties: TSQLDBConnectionProperties;
  begin
    try
        exit(TSQLDBZEOSConnectionProperties.Create(TSQLDBZEOSConnectionProperties.URI(dMySQL, FHost + ':' + FPort), FDatabase, FUsername, FPassword));
    except
    end;
    exit(nil);
  end;

begin
  if not Assigned(FConnectionProperties) then
    FConnectionProperties := CreateConnectionProperties;

  exit(FConnectionProperties);
end;

Now the Properties are created if Server is startet - else nil is returned.

Scenario 2

Start MySQL
Start Service
Use Service's ConnectionProperties

After a while stop MySQL
Using the *ConnectionProperties.ExecuteInlined* returns "Lost Connection to MySQL Server during query" error as expected.
Now start MySQL again.

Now using *ConnectionProperties.ExecuteInlined* returns "MySQL Server has gone away"

Is there a Auto Reconnect Option ?


Rad Studio 12.1 Santorini

Offline

#2 2017-08-01 13:52:55

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: MySQL Server has gone away

Ok found a solution in setting ConnectionTimeOutMinutes to a value


Rad Studio 12.1 Santorini

Offline

Board footer

Powered by FluxBB