Hello,
When I connect to a remote server (a server using internet ip connection) everything is fine, but after about 10 minutes inactivity if I want to do anything with the database e.g. insert there is an error message: "Lost connection to MySql server during query"
I use Delphi 2010 and MyDac 5.90.0.59
Can you help me? Thank you
Lost connection to MySql server during query
It seems that the value of the wait_timeout MySQL system variable is set to 10 minutes. You can find more information here:
http://dev.mysql.com/doc/refman/5.0/en/ ... it_timeout
http://dev.mysql.com/doc/refman/5.0/en/gone-away.html
You can solve the problem in two ways:
- by increasing the wait_timeout system variable value on the server;
- by using the OnConnectionLost event handler. Here is an example:
For more information, please refer to the MyDAC documentation.
http://dev.mysql.com/doc/refman/5.0/en/ ... it_timeout
http://dev.mysql.com/doc/refman/5.0/en/gone-away.html
You can solve the problem in two ways:
- by increasing the wait_timeout system variable value on the server;
- by using the OnConnectionLost event handler. Here is an example:
Code: Select all
procedure TMainForm.MyConnectionConnectionLost(Sender: TObject;
Component: TComponent; ConnLostCause: TConnLostCause;
var RetryMode: TRetryMode);
begin
RetryMode := rmReconnectExecute;
end;
Hello,
I set localFailover:=true
and
procedure TMainForm.MyConnectionConnectionLost(Sender: TObject;
Component: TComponent; ConnLostCause: TConnLostCause;
var RetryMode: TRetryMode);
begin
RetryMode := rmReconnectExecute;
end;
But the error message still pops up. It goes into the event because I also tried with a ShowMessage and it showed up .
I have no right to set the server's variable
I set localFailover:=true
and
procedure TMainForm.MyConnectionConnectionLost(Sender: TObject;
Component: TComponent; ConnLostCause: TConnLostCause;
var RetryMode: TRetryMode);
begin
RetryMode := rmReconnectExecute;
end;
But the error message still pops up. It goes into the event because I also tried with a ShowMessage and it showed up .
I have no right to set the server's variable
We have investigated this problem. In this case the 'Lost connection to MySQL server during query' error is an internal MyDAC error that is used for internal purposes. Such MyDAC behaviour is correct, it is caused by specificity of working with not fetched data. You will see the 'Lost connection to MySql server during query' error only if you run your application from IDE. You will not see this error when you run the executable file of your application.
I've just experienced this same problem. IDE or not, I still get a "Lost connection to MySQL server during query". Full Exception stack is below.
Error on reading data from IDataReader.
at Devart.Data.Linq.LinqCommandExecutionException.CanThrowLinqCommandExecutionException(String message, Exception e)
at Devart.Data.Linq.Provider.ObjectReader`1.MoveNext()
at System.Linq.Seq.d__20`1.MoveNext() in C:\dev\wrkspc.......:line 486
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Extract.KPIs() in C:\dev\wrkspc.................:line 162
Lost connection to MySQL server during query
at Devart.Common.aj.a(Exception A_0)
at Devart.Data.MySql.bh.a(Exception A_0)
at Devart.Common.s.e(Byte[] A_0, Int32 A_1, Int32 A_2)
at Devart.Data.MySql.bk.a(Byte[] A_0, Int32 A_1, Int32 A_2)
at Devart.Data.MySql.bk.a()
at Devart.Data.MySql.bk.b(Byte[] A_0)
at Devart.Data.MySql.u.a(Byte[] A_0)
at Devart.Data.MySql.u.a(Byte[] A_0, Boolean A_1)
at Devart.Data.MySql.an.f()
at Devart.Data.MySql.a2.b(Boolean A_0)
at Devart.Data.MySql.MySqlDataReader.a(Boolean A_0)
at Devart.Data.MySql.MySqlDataReader.System.IDisposable.Dispose()
at Devart.Common.l.a(Int32 A_0, Object A_1, Int32 A_2, Object A_3)
at Devart.Common.l.a.a(Int32 A_0, Int32 A_1, Object A_2, l A_3)
at Devart.Common.l.a(Int32 A_0, Int32 A_1, Object A_2)
at Devart.Common.DbConnectionInternal.a(Int32 A_0, Int32 A_1)
at Devart.Common.DbConnectionBase.Close()
at Devart.Data.MySql.MySqlConnection.Close()
Error on reading data from IDataReader.
at Devart.Data.Linq.LinqCommandExecutionException.CanThrowLinqCommandExecutionException(String message, Exception e)
at Devart.Data.Linq.Provider.ObjectReader`1.MoveNext()
at System.Linq.Seq.d__20`1.MoveNext() in C:\dev\wrkspc.......:line 486
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Extract.KPIs() in C:\dev\wrkspc.................:line 162
Lost connection to MySQL server during query
at Devart.Common.aj.a(Exception A_0)
at Devart.Data.MySql.bh.a(Exception A_0)
at Devart.Common.s.e(Byte[] A_0, Int32 A_1, Int32 A_2)
at Devart.Data.MySql.bk.a(Byte[] A_0, Int32 A_1, Int32 A_2)
at Devart.Data.MySql.bk.a()
at Devart.Data.MySql.bk.b(Byte[] A_0)
at Devart.Data.MySql.u.a(Byte[] A_0)
at Devart.Data.MySql.u.a(Byte[] A_0, Boolean A_1)
at Devart.Data.MySql.an.f()
at Devart.Data.MySql.a2.b(Boolean A_0)
at Devart.Data.MySql.MySqlDataReader.a(Boolean A_0)
at Devart.Data.MySql.MySqlDataReader.System.IDisposable.Dispose()
at Devart.Common.l.a(Int32 A_0, Object A_1, Int32 A_2, Object A_3)
at Devart.Common.l.a.a(Int32 A_0, Int32 A_1, Object A_2, l A_3)
at Devart.Common.l.a(Int32 A_0, Int32 A_1, Object A_2)
at Devart.Common.DbConnectionInternal.a(Int32 A_0, Int32 A_1)
at Devart.Common.DbConnectionBase.Close()
at Devart.Data.MySql.MySqlConnection.Close()
You posted your question at the wrong forum. Please post your question at the following forum: http://www.devart.com/forums/viewforum.php?f=2