I am using MyDAC 3.30.0.13 for Delphi 5
I have a problem with "Too Many Connections". I have made an object for each of my tables in my database. These objects are derieved from my "Standard" MySQL object for that database.
The Create and Destroy "procedures" are listed below. When the object is freed, the connection to the MySQL server is still there. Its Asleep, but still present. I keep creating and destoying objects and more and more connections is made. Until I get the Error "Too Many Connections" from MySQL. All the connections disapear only, when I stop my program.
Is there anyway of disconnecting the MySQL connection without stopping the program?
My other solution is to make the MyDAC MyConnection object part of my main object and remake all my Table object to have the MyConnection object passed to them as a parameter. ie: constructor TFRMySQL.Create(const AMyConnection: TMyConnection);
Is there a better way?
Best regards
Flemming Brandt
Code: Select all
////////////////////////////////////////////////////////////////////////////////
// Standard Methods //
////////////////////////////////////////////////////////////////////////////////
constructor TFRMySQL.Create;
begin
try
inherited Create;
fMyConnection := TMyConnection.Create(fOwner);
fMyConnection.OnError := ErrorMyConnection;
FRMySQLConnection(fMyConnection);
fMyQuery := TMyQuery.Create(fOwner);
fMyQuery.Connection := fMyConnection;
fMyQuery.OnDeleteError := ErrorDelete;
fMyQuery.OnEditError := ErrorEdit;
fMyQuery.OnPostError := ErrorPost;
fMyQuery.OnUpdateError := ErrorUpdate;
fRetries := 10;
fSetPropertyFailed := False;
except
fSetPropertyFailed := True;
fMessage := FRAddLfCR(fMessage) + '['+Self.ClassName+'.Create] Failed!!! *** ERROR UNKNOWN ***';
end;
end;
destructor TFRMySQL.Destroy;
begin
try
fMyQuery.Close;
FreeAndNil(fMyQuery);
fMyConnection.Close;
fMyConnection.Disconnect;
FreeAndNil(fMyConnection);
FreeAndNil(fOwner);
inherited;
except
fSetPropertyFailed := True;
fMessage := FRAddLfCR(fMessage) + '['+Self.ClassName+'.Destroy] Failed!!! *** ERROR UNKNOWN ***';
end;
end;