3 Question: Thread, TFormatSettings, Change windows date

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
maciejmt
Posts: 27
Joined: Sun 25 Apr 2010 14:14

3 Question: Thread, TFormatSettings, Change windows date

Post by maciejmt » Mon 20 Dec 2010 13:44

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)

AndreyZ

Post by AndreyZ » Tue 21 Dec 2010 08:48

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.

maciejmt
Posts: 27
Joined: Sun 25 Apr 2010 14:14

Post by maciejmt » Tue 21 Dec 2010 11:25

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

AndreyZ

Post by AndreyZ » Wed 22 Dec 2010 10:26

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.

maciejmt
Posts: 27
Joined: Sun 25 Apr 2010 14:14

Post by maciejmt » Wed 22 Dec 2010 13:00

Ok, I thought that this exception always appears when date is changed (Summer time -> Winter time), but Its ok. Thx.

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

Post by eduardosic » Thu 23 Dec 2010 13:52

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.

Post Reply