I have a hundred of users working remotly on a 4.1x MySQL server.
My application is opening a lot of queries. After a DB disconnection, the application is no more able to reconnect and user will get a lot of Access Violation.
Is there a way to "safely" handle mysql DB disconnection ? , to reconnect and have all queries still active
How to "safely" handle mysql DB disconnection
-
swierzbicki
- Posts: 451
- Joined: Wed 19 Jan 2005 09:59
Please specify exact error message you get. Are you able to locate exact place where error is raised?
> Is there a way to "safely" handle mysql DB disconnection ? , to reconnect and have all queries still active
Now this is possible if you use ClientDataset with MyDAC (MyConnection - MyQuery - DasetProvider - ClientDataSet). But in the next version of MyDAC we add support of Failover. It will allow you to reconnect to the server without closing recordsets.
> Is there a way to "safely" handle mysql DB disconnection ? , to reconnect and have all queries still active
Now this is possible if you use ClientDataset with MyDAC (MyConnection - MyQuery - DasetProvider - ClientDataSet). But in the next version of MyDAC we add support of Failover. It will allow you to reconnect to the server without closing recordsets.
-
swierzbicki
- Posts: 451
- Joined: Wed 19 Jan 2005 09:59
It looks like the new myDAC version behaves better then the olds one.
Now, after the disconnect, i'm only getting this errror message :
Lost Connection to MySQL Server during query
Socket Error on write. WSAGetlastError return 10054($2746)
All Queries are then closed.
Is it possible to catch this particular exception so that I will be able to automatically close all opened forms , and disable some of my Tactions ?
FWIW I'm not using the ClientDataset (moving to such structure will impact on "curent" code ? )
Thank you
Now, after the disconnect, i'm only getting this errror message :
Lost Connection to MySQL Server during query
Socket Error on write. WSAGetlastError return 10054($2746)
All Queries are then closed.
Is it possible to catch this particular exception so that I will be able to automatically close all opened forms , and disable some of my Tactions ?
FWIW I'm not using the ClientDataset (moving to such structure will impact on "curent" code ? )
Thank you
To handle lost connection try to put something like this into MyConnection.OnError event handler:
Code: Select all
uses
... MyCall;
...
procedure TForm.MyConnectionError(Sender: TObject; E: EDAError;
var Fail: Boolean);
begin
if (E.ErrorCode = CR_CONN_HOST_ERROR) or
(E.ErrorCode = CR_SERVER_LOST) or
(E.ErrorCode = CR_SERVER_GONE_ERROR) or
(E.ErrorCode = ER_SERVER_SHUTDOWN) then
ShowMessage('Connection lost');
end;-
swierzbicki
- Posts: 451
- Joined: Wed 19 Jan 2005 09:59