Page 1 of 1

3 Question: Thread, TFormatSettings, Change windows date

Posted: Mon 20 Dec 2010 13:44
by maciejmt
1) when I change date in calendar, then connection is wasted - (exception: lost connection to MySQL server during query). Why ?

2) How to cooperate AsString cast with TFormatSettings in TMyQuery object ? For example: I select decimal field from DB and I'd like that result of method AsString depends of TFormatSettings.DecimalSeparator.

3) I am projecting multi-thread application:
Is MyDAC thread-safe in 100% ? Ofc each thread has own instance of TMyConnection and connection is assigned by procedure (AssignConnect)

Posted: Tue 21 Dec 2010 08:48
by AndreyZ
Hello,

1. I cannot reproduce the problem. Please try composing a small sample to demonstrate the problem and send it to andreyz*devart*com.
2. You can manage the result of the AsString function by using the DecimalSeparator global variable. Also you can use the TNumericField.DisplayFormat property that determines how a numeric field value is formatted for displaying in a data-aware control. For more information please read Delphi Reference Manual.
3. The best way to work in a multithreaded application is to have a separate connection in each thread. In this case your application will be thread-safe.

Posted: Tue 21 Dec 2010 11:25
by maciejmt
It's very simple to reproduce it.
In each version of MyDAC it appeared.

//user root
//pass - Your pass
//schema - mysql

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  myquery1.SQL.Text := 'select user from user';
  try
    myquery1.Open;
  except on E: Exception do
  begin
    showmessage(e.Message);
    myquery1.Close;
  end;
  end;
  showmessage(myquery1.Fields[0].AsString);
  myquery1.Close;
end;

1) Execute this action, is OK !
2) Don't close application(TMyConnection), change Year(2010->2011) in Windows calendar and click button again
3) exception...................


btw.
Using globally variables like DecimalSeparator is deprecated by Delphi XE :P

Posted: Wed 22 Dec 2010 10:26
by AndreyZ
I have reproduced the problem. This is a MySQL problem and not MyDAC. You can check this using any other client, for example, MySQL Command Line Client. It seems that MySQL server closes connection by timeout. In this case the time difference between two queries is one year. Server takes it as inactivity time and closes connection.

Posted: Wed 22 Dec 2010 13:00
by maciejmt
Ok, I thought that this exception always appears when date is changed (Summer time -> Winter time), but Its ok. Thx.

Posted: Thu 23 Dec 2010 13:52
by eduardosic
maciejmt wrote:Ok, I thought that this exception always appears when date is changed (Summer time -> Winter time), but Its ok. Thx.
It's a mySQL problem, but you can use LocalFailOver to solve this.
using localfailover Mydac reconnect in background and no exption is raised.

see mydac demo.